如果另一个网站提出后到我的ASP.NET MVC 2的地盘,我怎么能抓住它?我需要对路线做任何事吗?ASP.NET MVC-2如何从另一个网站接收POST?
如其他网站做到这一点:
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);
我如何收到POST上我的网站?我曾尝试:
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
}
我不要管其他的网站,它必须是一个POST(而不是Web服务或其他任何东西)
至于另外一个奇怪的他们将发布约10变数,但也有一些可选,所以它们可能不在POST数据中。
固定错字 - 其他网站使用的是正确的URL http://mvc2-site.com/Controller/TestReceive – 2010-07-14 09:25:37
你得到它的工作使用Web客户端与2名PARAMS?我不能让公共字符串指数(串inputSegments,串cmdSubmit)workingusing TheWebClient.UploadValues() – VinnyG 2011-02-16 14:58:46