Calls to ASP.NET WebApi connection issue - asp.net-mvc

Currently I'm working on a ASP.NET MVC webapp which implemented a user dashboard where the user can add various charts to display data. We're using AngularJS for the client side to send the requests for data to a WebAPI solution.
The WebAPI action that returns the data is implemented as async - however, in the action we're querying some rather big Sql Server DB and apply various filters that the clients sets.
In case the user has more charts (10+) and he's "hitting" a big data set the Action on the WebAPI can take a bit of time to process.
My issue is that in Firebug I see all the GET requests being sent by AngularJS to the WebAPI, some of them (2-3) start being processed immediately, but the rest seems to get queued and in Firebug once they are finally processed I see that the Connecting time for them is huge.
Can anyone give me any idea and make understand why WebAPI doesn't seem to respond to all the requests immediately? What am I missing? Are there any settings that I could apply to improve the performance on the WebAPI?
Thank you in advance for any suggestions!
Andrei

Related

Architectural advice: How to synchronize SignalR messages with the backend?

First I want to describe the scenario:
Let's say I have an admin page where multiple different things are displayed.
The things displayed are sent by client devices (SignalR between admin <-> clients).
Clients can see what other clients send.
They can like this stuff.
Likes have an effect to the order of items on the admin side.
Everything that is send across SignalR has to be saved in the database (can be done async) for the simple reason when somebody refreshes the site (initial page load).
Admin side
At first I wanted to do my own polling with a 5s interval (ASP.NET Web API).
But that's not real time and that's not what I call good performance (the db is queried every time).
Now my problem is to make sure that the received items via SignalR from the clients are in sync with the database.
And also the order has to match. So I have to replicate a little of the business logic concerning the likes/votes in JavaScript and on and on.
This seems prone to errors.
What are your thoughts on this?
I have made a lib that fits very good when you want to catch events fired in backend and forward them to clients. Please see my answer here
How to use a Singleton Signalr client within an MVC application
Refreshing List of news using SignalR

Integrating SignalR with Other MVC Processes

I have a fairly simple MVC4 web application that accepts HTTP POST requests. The Controller responsible for the managing the POST request simply parses the form collection and creates an appropriate record in a SQL database table.
I would like to extend my application to provide an administration page that automatically updates each time a new POST is recorded. For the page architecture for this facility I was planning to use SignalR. I've used SignalR before, so I am fairly happy with the basic Hub/Client interaction, but what I don't know is what 'plumbing' I can use to get the SignlR Hub to monitor the events on the POST Controller or to put it another way, what the POST Controller needs to do to trigger some kind of event that the SignalR Hub can respond to.
I hope this makes sense, any suggestions would be much appreciated.
This is what you're looking for http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server#callfromoutsidehub

how to start asp.net mvc 4 ajax call

plaese guide me to start asp.net mvc 4 ajax enabled multi platform web application. I have a REST service hostrd in another domain, want to consume it. please guide me whether i need to access that service from javascript ajax call or
create models at server and request my server with ajax call. any guides links much appreaciated..
regards
ani
The exact way to consume your web service will depend on the content of this service, and how you want the user to interact, but, from my point of view, the server should be interacting with the webservice, and your user with your server. That is, as you guessed, "models" should reflect your web service data structure.
If you want to use ajax, use it to call methods in your controller(s) to load/update data from the webservice.
It's a bit difficult for me to go further without knowing what we are talking about, but to give you a better idea of what I am talking about, I wrote my own "API" to deal with Amazon Products Advertising API, using their rest service instead of SOAP. This same API is being used by 3 differents web applications.
Inside each web application there are AJAX calls to controller methods, who in turn calls my API methods.
This mechanism works perfectly in this case, but it may not in yours, which is why I believe you need to tell us a little more about hte kind of service and application you are going to build.
Sorry to stay a little vague, still hope this helps.
Bernard

Single page apps keeping client and server in sync

I am trying to understand how single page apps spa's work.
My understanding of a spa is that you load the data on start-up and you use ajax calls for save etc, and the whole idea is that your models cache data on the client so you have a rich snappy experience in your browser.
I am confused as to how the client stays in sync with the server changes.
E.G. If I have multiple users logged into my spa and they are all making changes, how does my client know that another user has updated a persons details if it is using cached data?
My guess is that something similar needs to happen server side to update the client on a change. Does this exist or am I misunderstanding something?
Any help or pointers to additional info would be much appreciated.
Thank you in advance.
For server to client communication you can use SignalR.
SignalR allows you to create a hub on the server which you can then tell to update the clients.
It works with a fallback mechanism, it tries to use the following techniques and falls back onto the next one if it's not available in the browser:
Web Sockets
server sent events
forever frame
long polling
Link for fallbacks: http://www.asp.net/signalr/overview/introduction/transports-and-fallbacks
Link for signalR: http://signalr.net/

Http handler for classic ASP application for introducing a layer between client and server

I've a huge classic ASP application where in thousands of users manage their company/business data. Currently this is not multi-user so that application users can create users and authorize them to access certain areas in the system.
I'm thinking of writing a handler which will act as middle man between client and server and go through every request and find out who the user is and whether he is authorized to access the data he is trying to.
For the moment ignore about the part how I'm going to check the authorization and all that stuff. Just want to know whether I can implement a ASP.net handler and use it as middle man for the requests coming for a asp website? I just want to read the url and see what is the page user is trying to access and what are the parameters he is passing in the url the posted data. Is this possible? I read that Asp.net handler cannot be used with asp website and I need to use isapi filter or extensions for that and that can be developed only c/c++.
Can anybody through some light on this and guide me whether I'm in the right direction or not?
Note: To be specific, I cannot modify anything in the existing application because there are hundreds of pages (each page again has couple of different actions, such as posted to the same page again) are there in the system and it is really big mess and we are coming up with a different solution to clear that mess but that takes couple of years to complete, meanwhile to provide the multi-user functionality to the users we are trying to do this. This layer acts like layer where we authorize the user to do certain operation or access a page, nothing more than this.
I've worked with an ASP classic website that runs Javascript on the server side. In IIS we selected JScript as the server-side scripting language and access the session variables and the database simultaneously to check user's access rights when they try to check out various parts of the site. What you're describing is completely do-able. Each page needs to have Javascript in <% %> tags and that identifies the content as server-side code. Be careful with security though!
As for the ASP.NET handler, I also developed an ASP.NET application that I added imported to our site (had to use a .NET thread pool) which could handle Ajax requests. IIS has this option to import ASP.NET applications to your site.
You've got options.

Resources