Created
October 23, 2017 09:31
-
-
Save johnw86/113f43574b2205636958665fde11317c to your computer and use it in GitHub Desktop.
Allow CORS in .net application
This file contains hidden or 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
| 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