如何在Global.Asax中处理Application_Error [英] How Do I Handle The Application_Error In Global.Asax
问题描述
大家好,
使用asp.net做一个电子商务网站c#
,我有一个添加两个数字的示例模块。
在这种情况下,如果我输入字符串值,那么页面将重定向到后面的代码。
但是我不想去代码后面的地方,
而不是我要展示的同一页面本身或使用global.asax文件的任何其他页面中的错误(Application_Error)
这意味着Application_error。
所以如何使用Application_Error文件处理页面错误
我的代码是:
Hi all,
Am doing one e-commerce website using asp.net with c#
in that i have a sample module that is adding two numbers.
in this case if i enter the string value then the page will redirect to the code behind place.
but i dont want to go to code behind place,
instead of that i want to show that error in the same page itself or any other page using global.asax file(Application_Error)
which means the Application_error.
so how do i handle my page error using Application_Error file
my code is:
protected void Button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text);
int b = Convert.ToInt32(TextBox2.Text);
int c = a + b;
TextBox3.Text = c.ToString();
}
thanks to all
推荐答案
这是不止一个错误处理解决方案。
请按照以下链接
ASP.NET应用程序错误处理 [ ^ ]
http://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-表单/ aspnet-error-handling [ ^ ]
ASP.NET中的错误处理 [ ^ ]
http://www.c-sharpcorner.com/UploadFile/de41d6/exceptionerror-handling-in-Asp-Net-simplified/ [ ^ ]
问候,
AARIF SHAIKH
Here is more than one solution for Error Handling .
Please follow below link for it
ASP.NET Application Error Handling[^]
http://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/aspnet-error-handling[^]
Error Handling in ASP.NET[^]
http://www.c-sharpcorner.com/UploadFile/de41d6/exceptionerror-handling-in-Asp-Net-simplified/[^]
Regards,
AARIF SHAIKH
https://msdn.microsoft.com/en-us/library/24395wz3.aspx [ ^ ]
ASP.NET应用程序错误H andling [ ^ ]
-KR
https://msdn.microsoft.com/en-us/library/24395wz3.aspx[^]
ASP.NET Application Error Handling[^]
-KR
这篇关于如何在Global.Asax中处理Application_Error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!