Created
October 16, 2013 15:19
-
-
Save sergeyt/7009430 to your computer and use it in GitHub Desktop.
global.asax to enable CORS on IIS server
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
<%@ Application Language="C#" %> | |
<script runat="server"> | |
void Application_BeginRequest(object sender, EventArgs e) | |
{ | |
var context = HttpContext.Current; | |
var response = context.Response; | |
// enable CORS | |
response.AddHeader("Access-Control-Allow-Origin", "*"); | |
response.AddHeader("X-Frame-Options", "ALLOW-FROM *"); | |
if (context.Request.HttpMethod == "OPTIONS") | |
{ | |
response.AddHeader("Access-Control-Allow-Methods", "GET, POST"); | |
response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept"); | |
response.AddHeader("Access-Control-Max-Age", "1728000"); | |
response.End(); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment