[研究][ASP.NET][C#] ELMAH - 錯誤通知信設定
[研究][C#] ELMAH - ASP.NET錯誤記錄模組 (Error Logging Modules and Handlers)(NuGet安裝)
2022-04-16
官方網站
https://code.google.com/p/elmah/downloads/list
https://www.nuget.org/packages/elmah/1.2.2
環境:Windows Server 2019 + Visual Studio 2019
{0} 是 Elmah errorMail 預設錯誤主旨
Default.axpx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br /> <asp:Label ID="Label1" runat="server"></asp:Label> </form> </body> </html> |
Default.aspx.cs
using System; namespace WebApplication1 { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Int32.TryParse(TextBox1.Text, out int a); Int32.TryParse(TextBox2.Text, out int b); Label1.Text = (a / b).ToString(); } } } |
第1個欄位隨便輸入整數,第2個欄位輸入0,按下按鈕,執行結果
(完)