GET and POST to ASP.NET MVC Controller
-
Friday, April 20, 2012 4:56 PM
Hello,
I have a Silverlight app for Windows Phone that I need to interact with my backend. My backend exposes GET and POST end points via ASP.NET MVC. I am already using these endpoints with JQuery. For instance, my end points look like this:
[AcceptVerbs(HttpVerbs.Get)] public ActionResult GetItem(string id, string caller) { // Do stuff } [AcceptVerbs(HttpVerbs.Post)] public ActionResult SaveItem(string p1, string p2, string p3) { // Do stuff }First, I'm not sure how do a GET with the WebClient in a way that allows me to pass in parameter values. Second, I'm not sure how to do a POST with the WebRequest object. We want to use the WebRequest because we had some performance issues with just the WebClient. Currently, I have the following:
WebRequest request = HttpWebRequest.Create("http://www.myapp.com/actions/AddItem"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.BeginGetResponse(new AsyncCallback(AddItem_Completed), request);Regardless, I'm not sure how to actually POST data (the parameters) back to my endpoints. Can someone give me some help? Thank you!
All Replies
-
Thursday, April 26, 2012 10:23 AM
a.paranoid.android
http://www.iwantmymvc.com/using-silverlight-with-mvc-and-json
However, Silverlight is like Desktop , I would prefer to use WCF Ria Service rather than JSON. It work with MVC.

