是否有关于 HttpModule 内部错误处理的任何指导资源?

发布于 2024-10-14 11:19:52 字数 471 浏览 2 评论 0原文

我试图找到有关处理 HttpModule 内部错误的最佳实践的任何信息,不幸的是我似乎无法在 Google 上找到与此相关的任何信息。

我发现的所有信息都与如何使用 global.asax 或自定义 http 模块来记录完全不相关的错误有关。

编辑:显然这个问题被误解了。我正在寻找有关用于防止 HttpModule 发生故障、触发自定义错误重定向以及再次发生故障导致无限异常链直到 IIS 完全关闭线程的软件模式的信息。

然而,这非常重要,因为 HttpModule 的生命周期不能依赖 HttpSessionState 集合。由于错误情况已经发生,因此期望我可以读取 ASP.NET 会话 cookie 来获取可以在应用程序缓存中存储用户特定数据的标识符是不合适的。将数据存储在 HttpRequest.Items 集合中是没有意义的,因为多个请求中根本不存在数据。

我的最终结论是我必须使用cookie来存储这些中间信息。

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 redirection, 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一江春梦 2024-10-21 11:19:52

正如 K Ivanov 所说,标准错误处理实践在这里与其他地方一样适用。

将代码包装在 try .. catch 语句中。然后适当地处理它们和/或记录它们以供进一步审查。日志记录可以采取多种形式,例如将信息存储到数据库中、写入文本文件等。HttpModule

没有什么特别之处。

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.

诗酒趁年少 2024-10-21 11:19:52

这个问题不太清楚,因为它没有表达您想要实现的目标的非常具体的用例。万一我部分理解了。您正在尝试查看是否有方法可以以根本不会终止进程的方式处理 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文