Live Chat Icon For mobile
Live Chat Icon

How to catch the 404 error in my web application and provide more useful information?

Platform: ASP.NET| Category: Basic

In the global.asax Application_error Event write the following code


Dim ex As Exception = Server.GetLastError().GetBaseException()
If TypeOf ex Is System.IO.FileNotFoundException Then
	’your code
	’your code
End If


Exception ex = Server.GetLastError().GetBaseException();
if (ex.GetType() == typeof(System.IO.FileNotFoundException)) 
	//your code
	Response.Redirect ('err404.aspx');
	//your code

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.