开发者

Accessing a master page from httphandler

I am developing a small application in asp.net (writing in c#). In my application I am using jquery to perform asynchronous call to the server. I have an http handler that listens in to the requests and does what it needs to do.

Problems start when in the handler I need to access information stored in the page , from where t开发者_如何学编程he asynchronous call started. When I try this:

 Page page = HttpContext.Current.Handler as Page;

I don't get a page.

How else can I access the page itself?

Thank you


You have a slight design issue. The Page class IS an HttpHandler. It is in fact the default HttpHandler that handles requests. When you define your own HttpHandler, there is no Page class... and hence no Master either.

If you need to access information from a different page, you need to do that via the normal ASP.NET mechanisms... Session, Cache, etc.


You can create new instance of page.

SomePage page = new SomePage();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜