CORS request not working in Windows Safari I am making a CORS request to upload a file i am using Plupload plugin to upload a file . This works fine in chrome, however when I run in safari I get an ' Origin http://localhost is not allowed by Access-Control-Allow-Origin.'. I have set the CORS on the server.
This is Request headers
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryLUZFR1paN3ARVMRv
Referer: http://localhost/PetaTracker/UploadView/machineView/LargeFile
What I have tried:
protected void Application_BeginRequest(object sender, EventArgs e)
{
try
{
EnableCrossDomainAjaxCall();
}
catch (Exception ex)
{
ErrorHandlerTools.LogError(ex);
}
}
private void EnableCrossDomainAjaxCall()
{
HttpContext.Current.Response.Headers.Remove("Access-Control-Allow-Origin");
Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.OK;
HttpContext.Current.Response.Headers.Remove("Access-Control-Allow-Methods");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "HEAD, GET, PUT, POST, COPY, OPTIONS, DELETE");
HttpContext.Current.Response.Headers.Remove("Access-Control-Allow-Credentials");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true");
HttpContext.Current.Response.Headers.Remove("Access-Control-Allow-Headers");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "origin,x-requested-with,content-Type,accept,x-auth-token,x-custom-header");
HttpContext.Current.Response.Headers.Remove("Access-Control-Max-Age");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}