Skip to content

Instantly share code, notes, and snippets.

@johnw86
Created October 23, 2017 09:31
Show Gist options
  • Select an option

  • Save johnw86/113f43574b2205636958665fde11317c to your computer and use it in GitHub Desktop.

Select an option

Save johnw86/113f43574b2205636958665fde11317c to your computer and use it in GitHub Desktop.
Allow CORS in .net application
protected void Application_BeginRequest()
{
if (Request.Headers.AllKeys.Any(x => x.ToUpper() == "ORIGIN") && Request.HttpMethod.ToUpper() == "OPTIONS")
{
Response.Flush();
}
}
<customHeaders>
<remove name="X-Powered-By" />
<add name="X-Frame-Options" value="SAMEORIGIN" />
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS"/>
<add name="Access-Control-Allow-Headers" value="Content-Type"/>
</customHeaders>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment