Problem
With Webuploader web upload plugin for cross-domain upload, only IE can be successful, after 1 days of debugging to find the problem lies
When Ajax is uploaded, an options preflight request is sent first, but in the IIS configuration
No request to allow options
So I add breakpoint debugging on the server to find the request is not going to the service side of the method, and when using IE, ie there is no pre-test request, so IE can be debugged successfully
Solutions
Add the Allow options condition, test again, solve the problem
Put the code on the service side, a general handler
<%@ WebHandler language="C #"class="Receive"%>usingSystem;usingsystem.web;usingSystem.IO; Public classreceive:ihttphandler{ Public voidProcessRequest (HttpContext context) {if(Context. Request.HttpMethod.Equals ("OPTIONS") {context. Response.clearcontent (); Context. Response.AddHeader ("Access-control-allow-origin","http://localhost:61269"); Context. Response.AddHeader ("Access-control-allow-methods","POST, GET, OPTIONS"); Context. Response.AddHeader ("access-control-allow-headers","Content-type"); Context. Response.AddHeader ("Access-control-max-age"," -"); Context. Response.End (); } Else if(Context. Request.HttpMethod.Equals ("POST")) { varFiles =context. Request.Files; for(inti =0; I < files. Count; i++) { varFile =Files[i]; varFilePath =@"E:\PIC\"+path.getfilename (file. FileName); File. SaveAs (FilePath); } context. Response.AddHeader ("Access-control-allow-origin","http://localhost:61269"); } } Public BOOLisreusable {Get { return true; } }}
The key to cross-domain is to include in the response header
access-control-allow-origin:*
If the request header has origin, the Access-control-allow-origin value cannot be * and must be a URL
Ajax cross-domain knowledge reference
http://blog.csdn.net/net_lover/article/details/5172522
Web Upload plugin webuploader---Cross-domain upload problem summary