Issue with PageMethods when following best practices in a web app

Thread is closed for posting
4 posts, 0 answers
  1. Josh
    Josh avatar
    12 posts
    Member since:
    Aug 2008

    Posted 26 May 2009 Link to this post

    Hi,

    I have been setting up a web application with Open Access and I have been very happy with the product.  I was following the best practices by using an HTTP module for containing the ObjectScope and I have run into an issue.  When following this,  I am not seeing the HTTP module's PreRequestHandlerExecute method being invoked when calling PageMethods from an ASP.Net page.  This means that the ObjectScope is not available in the session when running code through the PageMethod.  I am running this solution under VS 2008 and using the development web server that ships with it.  At first I thought it might be the fact that the url is http://localhost/mypage.aspx/<pagemethod name> and it is not treating it exactly like an ASPX page but everything I have read said that The development server should route all requests through the asp.net pipeline.  If needed, I can send you a quick sample project showing the behavior.

    Do you have any suggestions on how to work around this? 

    Thanks!
  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 28 May 2009 Link to this post

    Hi Jim,
    Just instantiate the ObjectScope where you need it, wherever you use it and it is still null retreive one. Add the check to the scope. Dispose() call as well.

    All the best,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Josh
    Josh avatar
    12 posts
    Member since:
    Aug 2008

    Posted 31 May 2009 Link to this post

    Thanks for the answer.  We ended up setting up our scope object in a different manner than in your web application examples.  It turns out that when using a REST based call, as used with page methods, the ASP.net runtime will short circuit the page life cycle and the PreRequestHandlerExecute method in my custom HTTP module never gets called.


  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 05 Jun 2009 Link to this post

    Hello Jim,

    Yes, there are issues in some scenarios in the HttpModule way of object-scope management. Have you considered the latest approach, using the HttpContext.Items collection that we have described in our latest KB article. It has so far proven to be very convenient for every web-scenario where master-pages way of obtaining the object scope is not proffered or applicable.

    All the best,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top