问题说明一切,拿这个例子代码:
<ul id="css-id">
<li>
<something:CustomControl ID="SomeThingElse" runat="server" />
<something:OtherCustomControl runat="server" />
</li>
</ul>
现在,如果在这些控件(位于母版页中)的某处抛出错误,它们将关闭整个站点,如何捕获这些异常?
最佳答案
您可以捕获所有未在 Global.asax 页面/类的其他地方处理的异常。 看:
protected void Application_Error(Object sender, EventArgs e)
方法。
关于c# - 在 .aspx 和 .ascx 页面中捕获异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/138071/