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
Related
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
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
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
A 3rd party site sends its notifications after my web application has completed some action in order to notify me of its success. Receiving a notification item requires a response back to the 3rd party server (URL) with the a containing the value "accepted".
I have never user SOAP and with the basic info found I'm a bit lost for the case of asp.net mvc. Are there any good links showing the principle of receiving and sending SOAP responses?
Tutorials / information may be presented in other languages such as java, asp.net (classic) or something. I need to get a general idea since googling on SOAP has not given me anything for the past few hours.
You need to learn a little about WCF. See the WCF Developer Center, especially the Beginners Guide.
What you want is to create a simple WCF service that corresponds to the WSDL that they will give you. You will need to implement only the operation (method) that they will call to notify you. You can host a WCF service in IIS along with the rest of your application.
The issue will be how to correlate the notifications with the page you're on in your MVC application.
I don't think this is specific to ASP.NET MVC really. If you have a WSDL for their web service, just use that to generate stub classes using either wsdl.exe or by adding a web reference to your project, then call the web service from your controller.
If I remember correctly SOAP is basically xml requests and responses.
You might want to look into WSDL (Web Service Definition Language) to avoid having to deal with raw data, and you would likely find a great deal of tutorials on wsdl as well.
I want to do a cross sub domain post in asp.net mvc and as the post data ,i want to pass an object which will be used in the recieving action in controller .Can anyone suggest how i can do that?
There are two applications .Application 1 needs to open application2 in a separate browser and post some data to it which application 2 will use to render some stuff.Sorry for not being clear but they are actually under the same parent domain but different subdomains.Both the applications are mvc applications.
If both sites are in your control, then you could have a service on the server that talks to both and send data via the service from one site to the other.
If one site is out of your control, then I'm not sure that cross domain posting is a good idea.