locked
Custom HttpModule is not called when used Server.Transfer RRS feed

  • Question

  • User-108976780 posted

    I have code in my project which changes the URL containing the text as querystring to number to get the data from the database. I am checking the querystring in page load and if it contains the name rather than the number I am mapping it to the numeric key. Now I have to execute the page life cycle again. I had two choice either use the

    Response.Redirect

    but I do not want the URL in the client browser to change so I went with the

     Server.Transfer

    The problem I started facing is that I have a custom httpmodule which is used to log the URLs in the database. I realized that

     BeginRequest

    in the http module is not firing after the

     Server.Transfer

    My application is working fine in the case of

     Response.Redirect.

    I am not sure how and why Server.Transfer is skipping my HttpModule and if it is how it works ?

    Wednesday, November 20, 2013 3:02 AM

Answers

  • User465171450 posted

    It's not that the HttpModule is skipped, it's that it already was called. When you use Response.Redirect, you send a 302 redirect signal to the browser, which then makes a new request. When you use Server.Transfer, all you are doing is continuing the existing request that already made it past your BeginRequest module. All Server.Transfer really does is pass control along to this other page. Since it's done on the server, and is essentially a continuation of the same request it won't be called again.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 20, 2013 3:28 AM