我的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