Last active
May 8, 2020 04:30
-
-
Save tonidy/c20af522e859dc887ef871cda4be9c35 to your computer and use it in GitHub Desktop.
Global.asax.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taken from https://blogs.msmvps.com/kenlin/2018/01/18/2694/ | |
protected void Application_BeginRequest(object sender, EventArgs e) | |
{ | |
if (HttpContext.Current.Request.HttpMethod == "OPTIONS") | |
{ | |
//These headers are handling the "pre-flight" OPTIONS call sent by the browser | |
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); | |
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept"); | |
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true"); | |
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000"); | |
HttpContext.Current.Response.End(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment