如何在使用 ELMAH 时遇到 MVC3 区域异常
我们正在尝试根据使用 ELMAH 时遇到异常的区域向不同的人发送电子邮件。我们一切正常,除了能够找出异常发生在哪个区域的能力之外。是否有一种简单的方法来获取表示最初从 ELMAH 内抛出异常的 MVC3 区域的字符串?
本质上,我们希望controllerContext.RouteData.DataTokens["area"]作为字符串返回什么,但不知道如何从Elmah中获取controllerContext。
谢谢!
We are trying to email different people based on what area an exception was hit in using ELMAH. We have everything working, except the ability to figure out what area an exception was hit in. Is there an easy way to get the string representing the MVC3 Area where an exception was initially thrown from within ELMAH?
Essentially, we want what would be returned by controllerContext.RouteData.DataTokens["area"] as string
but don't know how to get the controllerContext from within Elmah.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信 Elmah 知道哪个控制器触发了初始异常。
然而,解决此问题的一种方法是将 AREA 名称添加到每个请求的请求缓存中。一旦它到达那里,假设异常发生在你把它放在那里之后,你应该能够获取它。
I don't believe Elmah knows anything about which controller triggered the initial exception.
One way you can solve this problem, however, is to add the AREA name to the Request Cache on every Request. Once it's there, assuming the exception happens after you put it there, you should be able to fetch it.