I have to build small MVC3 ASP.NET based portal that will receive data in JSON form from other also MVC3 ASP.NET based web service. Service will get data from database, serialize it, and send it as JsonResult. Portal needs to capture that data and deserialize it back to model and toss it to the appropriate view.
As I’m kinda new to this, I was thinking to use WebClient for web portal, but I don’t know if there is something better than that? Idea is to process data within controller.
Also, I would appreciate any examples/tutorials.
Thanks
I have literally just done this. I created a generic class to consume external web services using the HttpWebRequest and HttpWebResponse class’s.
Arguements for using the HttpWebRequest class could be that I believe you get more granular control when using HttpWebRequest, as the WebClient class is essentially a wrapper for the HttpWebRequest. And then de-serialize the Web Service responses into custom objects in your Web Portal App.
I would also not process the data in the controller and keep them cleaner, i abstracted this task to a Service class where any validation / modifications needed to be done on the responses.