Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using PreSendRequestHeaders Event in global.asax

I tried to assign the PreSendRequestHeaders Event in the global.asax file in the "Application_Start" method. But this does not work.

private void Application_Start()
{
    PreSendRequestHeaders += OnPreSendRequestHeaders;           
}

private void OnPreSendRequestHeaders(object sender, EventArgs e)
{
   // this is not called
}

The OnPreSendRequestHeaders is not called, why? Is it possible to assign the PreSendRequestHeaders method in the global.asax?

like image 944
Chris Avatar asked Jul 02 '12 18:07

Chris


1 Answers

Just use:

protected void Application_PreSendRequestHeaders(Object source, EventArgs e)
{

}

Or instantiate the handler:

protected void Application_Start()
{
    PreSendRequestHeaders += new EventHandler(OnPreSendRequestHeaders);
}

protected void OnPreSendRequestHeaders(object sender, EventArgs e)
{
    // should work now
}
like image 67
pklosinski Avatar answered Nov 15 '22 16:11

pklosinski