As part of Global.asax‘s BeginRequest event I conditionally add a CORS header based on a web.config value.
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
I lose this header when an HTTP 500 occurs. I’ve stepped through my code and the current response still maintains the headers throughout the Error event. Is there something else I can override that is flushing this headers?
Edit: The EndRequest event shows that the custom headers are missing and it looks like I can add them there instead. will update after
Not sure exactly what happens during the process but adding an event to
EndRequestand checking for 500 allowed me to successfully add the headers back in.