我的Sencha Touch应用程序正在向我的asp.net-mvc-3 WebService发布表单,但不是发送POST
而是发送OPTIONS
。如何处理ASP.NET MVC中的“选项方法”
我正在读一个类似的线程here,但我只是不知道如何处理我的代码中的OPTIONS
方法。
我曾尝试将[AllowAjax]
属性添加到我的Action中,但它似乎并不存在于MVC3中。
OPTIONS/GetInTouch/CommunicateCard HTTP/1.1
主机:webservice.example.com
的Referer:http://192.168.5.206/ 访问控制请求-方法:POST
产地:http://192.168.5.206
User-Agent:Mozilla/5.0(Macintosh; Intel Mac OS X 10_7_0)AppleWebKit/534.24(KHTML,如Gecko)Chrome/11.0.696.71 Safari/534.24
Access-Contro 1-请求报头:X-请求-随着,内容类型
接受:/
接受编码:gzip,放气,SDCH
接受语言:EN-US,EN; Q = 0.8
接收字符集:ISO-8859-1,UTF-8,q = 0.7,*; q = 0.3
在我ActionMethod,我使用下面的代码。
public JsonpResult CommunicateCard(CommunicateCard communicateCard)
{
// Instantiate a new instance of MailMessage
MailMessage mMailMessage = new MailMessage();
// removed for security/brevity
// Set the body of the mail message
mMailMessage.Body = communicateCard.name; // THIS IS CURRENTLY BLANK :-(
// removed for security/brevity
mSmtpClient.Send(mMailMessage);
// do server side validation on form input
// if it's valid return true
// else return false
// currently returning NULL cuz I don't care at this point.
return this.Jsonp(null);
}
使用您发布的代码,我可以获得[Plupload](http:// http://www.plupload.com /)在各个网站上工作。我不知道为什么它在使用OPTIONS HTTP方法而不是POST之前保持不变,所以谢谢! –
嗯,这不会返回正确的标题,以响应对我的选择请求:(... http://stackoverflow.com/questions/37216939/cors-requests-and-mvc5 – War