> For the complete documentation index, see [llms.txt](https://premanand-r.gitbook.io/weird-errors/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://premanand-r.gitbook.io/weird-errors/master.md).

# CORS Policy - Response to Preflight - Request doesn't pass access control check

&#x20;A CORS preflight request is a [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) request that checks to see if the CORS protocol is understood and a server is aware using specific methods and headers.&#x20;

<https://developer.mozilla.org/en-US/docs/Glossary/Preflight\\_request>

**.Net WebForms**

```aspnet
protected void Application_BeginRequest(Object sender, EventArgs e)
{
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
    if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
    {
        HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
        HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
        HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
        
        HttpContext.Current.Response.End();
    }

    string hostName = Request.Url.Host;
}
```
