GET and POST to ASP.NET MVC Controller

    General discussion

  • 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:

    public ActionResult GetItem(string id, string caller) 
      // Do stuff 
    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(""); 
    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!

    Friday, April 20, 2012 4:56 PM

All replies