Why HttpContext.Current.Handler is null?

前端 未结 4 961
长发绾君心
长发绾君心 2020-12-18 00:42

I\'m trying to access a Page within an HttpModule and I think I should do this by calling HttpContext.Current.Handler (This should reference the current page) but I\'m getti

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 01:14

    In AuthorizeRequest and AuthenticateRequest, the handler has not been created yet. (A handler should not be created if the request is denied) Therefore, this property is null.

    Why do you the Page, and what are you trying to do?

    You could try handling PostMapRequestHandler, which occurs after it resolves the Page, and throwing an HttpException or calling Response.End if you decide to deny the request.

    However, please note that to get an instance of the handler, its constructor must run; make sure it doesn't do anything critical or sensitive.

提交回复
热议问题