使用 AJAX 进行 ASP.Net healthMonitoring
目前,在我们所有的环境中,我们都打开了健康监控,以便在用户引起错误时向我们发出警报:
<healthMonitoring enabled="true">
<providers>
<add name="MailWebEventProvider" type="System.Web.Management.SimpleMailWebEventProvider" to="[email protected]" from="[email protected]" buffer="false" subjectPrefix="prefix: "/>
</providers>
<rules>
<add name="All errors from my site" eventName="All Errors" provider="MailWebEventProvider" profile="Critical"/>
</rules>
</healthMonitoring>
我们最近开始实现更多 AJAX 功能,我刚刚意识到部分页面更新期间抛出的任何错误都不会触发健康监控发送电子邮件。 用户得到默认的alert()消息框; 但是,服务器端没有任何内容。
有谁知道如何打开此功能? 我不确定我缺少什么设置
编辑
我看到 ScriptManager 控件有一个名为“AsyncPostBackError”的事件。 如果我挂上这个并执行“抛出 e.Exception”,它将触发运行状况监视器; 但是,它会消除用户看到的错误。 有谁知道如何在不抛出这样的错误的情况下触发健康监视器?
Currently, in all of our environments we have healthmonitoring turned on to alert us when ever a user has caused an error:
<healthMonitoring enabled="true">
<providers>
<add name="MailWebEventProvider" type="System.Web.Management.SimpleMailWebEventProvider" to="[email protected]" from="[email protected]" buffer="false" subjectPrefix="prefix: "/>
</providers>
<rules>
<add name="All errors from my site" eventName="All Errors" provider="MailWebEventProvider" profile="Critical"/>
</rules>
</healthMonitoring>
We recently started implementing more AJAX functionality, and I just realized any error thrown during a partial page update does not trigger the healthmonitor to send the email. The user gets the default alert() message box; however, nothing on the server side.
Does anyone know how to turn this on? I'm not sure what setting I'm missing
Edit
I see that the ScriptManager control has an event called "AsyncPostBackError". If I hook onto this and do "throw e.Exception", it will fire off the health monitor; however, it erases the error the user sees. Does anyone know how to fire the health monitor without throwing an error like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否是您正在寻找的内容,但在查看此处,此处,以及此处,看起来您可以创建可以从后台代码调用的自定义 Web 事件。 因此,您可以从导致部分页面回发的函数中调用这些处理程序,从而在服务器上留下通知。
特别检查第一个链接; 它详细介绍了如何构建自定义网络事件。
Not sure if this is what you are looking for, but after looking here, here, and here, it looks like you can create custom web events that you can call from your code behind. So, you can call these handlers from the functions causing the partial page postback to leave a notification on the server.
Check the first link especially; it details how to build a custom web event.
根据 Matthew 的建议,我想出了这个:
AjaxWebErrorEvent 是这样的:
Going with Matthew's suggestions, I came up with this:
Where AjaxWebErrorEvent is this: