“请求在此上下文中不可用”关于嵌套用户控件
我有三个对象:
- 一个页面,其中包含
- 一个用户控件 (A),其中包含
- 另一个用户控件 (B)
该场景是用户控件 A 中的一个事件被调用,此处仍然可以访问请求对象。但在该调用期间,我尝试通过用户控件 B(用户控件 A 的子类)再次调用 Request,并且它开始抛出“请求在此上下文中不可用”。
Request 对象是否仅限于事件调用者?
示例代码:
protected void MainGridPanel_RowClicked( object sender, EventArgs e )
{
int id = 1
windowedModuleDetailList.ModuleDetailListPresenter.GetById( id );
moduleDetailWindow.Show();
}
moduleDetailWindow 在本例中是子控件 B。 Show 方法内部执行的代码并不相关,因为当它进入其范围时,我在调试期间进行了检查,并且 Request 对象已经无法访问。
编辑: 由于某些外部工具的原因,无法选择使用 HttpContext.Current.Request。我真的很想知道为什么 Request 对子控件不可见。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您始终可以使用 HttpContext.Current.Request 来调用当前 Http 上下文上的 Request 对象。如果您使用此语法,请发布您的代码,以便我们查看并提出解决方案。
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.