Chris
Chris

Reputation: 4505

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?

Upvotes: 9

Views: 11620

Answers (1)

pklosinski
pklosinski

Reputation: 229

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
}

Upvotes: 12

Related Questions