If another website is making a POST to my ASP.NET MVC 2 site, how can I capture it? Do I need to do anything to the routes?
eg The other site does this:
string url = "https://mvc2-site.com/TestReceive"; // that's my site's controller action
NameValueCollection inputs = new NameValueCollection();
inputs.Add("SessionId", "11111");
System.Net.WebClient Client = new WebClient();
byte[] result = Client.UploadValues(url, inputs);
How do I receive that POST on my site? I have tried:
public ActionResult TestReceive(FormCollection fc) {} // doesn't get hit
public ActionResult TestReceive(string SessionId) {} // method gets hit but session id is null
public ActionResult TestReceive()
{
var param = ControllerContext.RouteData.Values["parameter"].ToString(); // Values["parameter"] is null
}
I do not control the other site and it must be a POST (not a webservice or anything else)
As another twist they will POST around 10 variables, but some are optional, so they may not be in the POST data.