Web Upload plugin webuploader---Cross-domain upload problem summary

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.