views:

68

answers:

1

I have three objects:

  • A Page which contains
  • A User Control (A) which contains
  • Another User Control (B)

The scenario is an event in User Control A gets called, the Request object is still accessible here. But during that call, I attempt to call Request again through User Control B, User Control A's child class, and it starts throwing the "Request is not available in this context".

Is the Request object restricted only to the event caller?

Sample code:

    protected void MainGridPanel_RowClicked( object sender, EventArgs e )
    {
        int id = 1

        windowedModuleDetailList.ModuleDetailListPresenter.GetById( id );
        moduleDetailWindow.Show();
    }

moduleDetailWindow is child control B in this case. It's not relevant what code is done inside of the Show method because when it enters its scope, I do a check during debug, and the Request object was already inaccessible.

EDIT: Due to some external tools, using HttpContext.Current.Request is not an option. I'd really like to know why Request isn't visible to the child control.

A: 

You can always use HttpContext.Current.Request to invoke the Request object on the current Http context. If you're using this syntax, please post your code so we can take a look at it and propose a solution.

Prutswonder
I added some code but I'm not using HttpContext.Current.Request because of some third party tools that (I'm assuming) use Request which is the cause of some other errors.
Jonn
Not sure what you mean with "HttpContext.Current.Request is not an option", because it's a generic way to address the Request object. Did you experiment with it to see if it solves the problem? Or does the error occur within the third-party control?
Prutswonder
HttpContext.Current.Request definitely works. But some third party controls I'm using seems to call the local Request object internally.
Jonn
As long as they are not the ones causing the errors, then there is nothing to worry about. The local Request object is the same as the HttpContext.Current.Request if the current context is available.
Prutswonder