开发者

Are there any guidance resources available in regards to error handling INSIDE of HttpModules?

开发者 https://www.devze.com 2023-02-06 21:29 出处:网络
I attempted to find any information in regards to best practices of handling errors inside of a HttpModule unfortunately I can\'t seem to find any information on Google in regards to this.

I attempted to find any information in regards to best practices of handling errors inside of a HttpModule unfortunately I can't seem to find any information on Google in regards to this.

All the information I've found all pertains in how to use the global.asax or a custom http module to log errors which is completely not pertinent.

Edit: Clearly this question has been misunderstood. I am seeking information regarding software patterns that are employed to prevent a HttpModules from faulting, triggering custom errors redirec开发者_JAVA百科tion, and faulting again causing infinite exception chains until IIS shuts down the thread entirely.

This however is very nontrivial since the HttpSessionState collection can't be depended on for the life cycle of HttpModules. Since error conditions have already occurred it would be improper to expect that I could read the ASP.NET session cookie to get an identifier that I could store user specific data in the application cache. Storing data in the HttpRequest.Items collection would be pointless since that in no way exists across multiple requests.

My final conclusion was that I had to use cookies to store this intermediary information.


As K Ivanov said, standard error handling practices apply the same here as anywhere else.

Wrap your code in try .. catch statements. Then handle them appropriately and/or log them for further review. Logging can take forms such as storing the info into a database, writing to a text file, etc.

There is nothing really special about HttpModules.


The question is not really clear because it doesn't express a very specific use case of what you are trying to achieve. In case I partially understood. You are trying to see if there are ways to handle errors of HTTPmodules in a way that would not kill your process at all.

  • ASP.NET Error Handling Using HttpModule, Full and Partial Post Back (Ajax UpdatePanel)
  • Exception handling using an HttpModule
0

精彩评论

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

关注公众号