I am working on web role in the Azure cloud service. Basically my web role is an MVC application and how can I make the controller in MVC communicate with the webrole.cs class. For example, in the run() method in webrole.cs I have received a message and I want to pass it to the MVC controller, how can I do that?
Any help is appreciated!
You'd better use a azure service bus queue to do that. Send a message on Run, and take the message from queue in your mvc app.
Related
I am planning to have both MVC and WEB API controllers in the same project. How do I separate those controllers when they are invoked from client application like angular. Whats the best preferred way to separate those (by verb/method name). Thank you.
Suppose you are requesting a MVC index ActionResult of controller named Home then the request will be like
http://yourdomain.com/Home/index.
and if you requesting a web api Get method which controller name is Service then request will be like this
http://yourdomain.com/api/Service
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
I have use wcf web service for data connectivity and all data related operation.
So, In my application, i need to integrate MVC controller pass or get model using the WCF webservice.
Please help how to pass model to WCF webservice from controller and How to get that Model or list of items into Controller ???
It is a bad idea to pass your actual controller to the WCF service. You don't want to couple your view tightly with the data contract of an external service.
Create a separate ViewModel that fulfills the needs of the view. Then implement code in the ViewModel to call the web service to update data and a static factory method on the ViewModel that creates a new ViewModel instance by retrieving data from the web service and populating a ViewModel instance.
I have use the TryUpdateModel method on the controllers but now I need to use it on a web service (.asmx).
Have anybody achieve this?
Thanks for your help...
The TryUpdateModel method is part of ASP.NET MVC. You cannot use it outside. In a web service you don't need it because usually requests and responses are serialized into objects automatically.
My ASP.NET MVC controller constructors create an instance of a service class by supplying it with (among other things) a ModelStateWrapper (similar to this article). Since this object is handled through a reference, any changes made to it in the service are reflected when the controller accesses that ModelStateWrapper object.
I need to convert that logical service layer into WCF services that will be hosted in IIS.
Assuming I want to continue performing validation in the service layer, which approach is better?
Pass the ModelStateWrapper object by reference (possible according to MSDN) with each service operation
Keep track of errors in the service and have the client explicitly retrieve a list of errors after any/all service operations are performed
Any other suggestions or links to articles that would help me perform validation behind a WCF service?
It should be noted that these services will eventually be consumed by a variety of UIs (ASP.NET MVC, Winform, Console, maybe even third-party).
Since you already have everything in place and working, pass the ModelStateWrapper over the wire to WCF service. Let it fill it out and send back.
The other platforms can use this same wrapper to get the error information.