Using the PreSendRequestHeaders Event in global.asax

I tried to set the PreSendRequestHeaders event in the global.asax file in the Application_Start method. But that does not work.

private void Application_Start() { PreSendRequestHeaders += OnPreSendRequestHeaders; } private void OnPreSendRequestHeaders(object sender, EventArgs e) { // this is not called } 

OnPreSendRequestHeaders not called, why? Can I assign a PreSendRequestHeaders method to global.asax?

+6
source share
1 answer

Just use:

 protected void Application_PreSendRequestHeaders(Object source, EventArgs e) { } 

Or create an instance of the handler:

 protected void Application_Start() { PreSendRequestHeaders += new EventHandler(OnPreSendRequestHeaders); } protected void OnPreSendRequestHeaders(object sender, EventArgs e) { // should work now } 
+7
source

Source: https://habr.com/ru/post/919518/


All Articles