locked
Pre-Process before browser hits a .ashx RRS feed

  • Question

  • User1043849133 posted

    Hello there. Im new to the forums and not deeply experienced with asp.net development, but im a fast learner.

        What im tryng to acomplish here is somehow something simple but im not managing to know where to start from. All i want to do, is to have a pre-process before a http request arrives at a .ashx page, for instance a user would try to acess that page, and before the page is actually acessed some code somewhere else (not in the page, something independant) runs certain validations/specifications to know if the user has to be redirected to another page.

       I would really apreciate any information about on how to proceed, something tells me it has something to do with HttpHandlers thats the reason im posting in here.

       Thanks alot for any attention !

       Best Regards, Gabriel A.k.a WololoDude

    Friday, August 30, 2013 2:09 PM

All replies

  • User1275632693 posted
    Have a read from this post: http://forums.asp.net/t/991225.aspx/1?ProcessRequest+in+Handler+ashx It helps put the whole thing into perspective and might be a good starting point.
    Friday, August 30, 2013 2:37 PM
  • User1043849133 posted

    Thanks alot for your attention !

    Ive managed to build the 'interception' with sucess, but now i got another problem to work with. Is it possible to continue to the resource im looking for after ProcessRequest has handled the httprequest ?

        Ive only managed to interrupt the page loading with sucess but didnt managed to keep thro the pages content.

       Again, thanks alot for the attention !

      Best Regards, WololoDude

    Friday, August 30, 2013 3:37 PM
  • User1275632693 posted
    Have you tried running through all the steps in Debug Mode, so you can see the process flow and get an idea of where things are at. I would also check the page life cycle just to see if there is a step in the cycle you can do your intercept in.
    Friday, August 30, 2013 5:07 PM
  • User1043849133 posted

    Ive read how the cycle works and debugged as i could, but i couldnt figure out on how to achieve that. I want to write in the response, the original page that was requested  (somehow like if there was no pre-processing) but i couldnt figure out how to do it. Is there any simple example of it ?

      Thanks alot for your attention !

      best regards, WololoDude

    Monday, September 2, 2013 12:54 PM
  • User-742633084 posted

    Hi WololoDude,

    If you want to intercept the incoming request to an ASP.NET server-side resource such as ASPX page, ashx handler or other custom HTTP handler, I think building a custom Http Module would be a good choice. The HTTP module sit inside the ASP.NET server-side build-in pipeline and intercept the request before it is processed by the final handler (custom http handler or aspx page handler). So we can perform some pre-processing such as validation, authentication... code logic there.

    #HTTP Handlers and HTTP Modules Overview
    http://msdn.microsoft.com/en-us/library/bb398986(v=vs.100).aspx

    #Walkthrough: Creating and Registering a Custom HTTP Module
    http://msdn.microsoft.com/en-us/library/ms227673(v=vs.100).aspx

     

    Tuesday, September 3, 2013 2:10 AM