Skip to content

Instantly share code, notes, and snippets.

@shammelburg
Last active November 26, 2015 21:26
Show Gist options
  • Save shammelburg/2185de2f0dfae0041d61 to your computer and use it in GitHub Desktop.
Save shammelburg/2185de2f0dfae0041d61 to your computer and use it in GitHub Desktop.
Angular Web API Access
// Add to Global.asax.cs
protected void Application_BeginRequest()
{
if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS")
{
Response.Flush();
}
}
/* web.config */
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type,Authorization" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment