捕获.aspx和.ascx页面中的异常

thr*_*thr 2 .net c# asp.net error-handling exception

问题说明了一切,拿这个例子代码:

<ul id="css-id">
    <li>
    <something:CustomControl ID="SomeThingElse" runat="server" />
    <something:OtherCustomControl runat="server" />
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

现在,如果在这些控件(位于母版页中)的某个位置抛出错误,它们将取消整个站点,如何捕获这些异常?

Dre*_*ejc 5

您可以捕获Global.asax页面/类中未处理的所有异常.看着:

protected void Application_Error(Object sender, EventArgs e)
Run Code Online (Sandbox Code Playgroud)

方法.