473,385 Members | 1,292 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to tell if Application_Error is caused by HTTP error 404?

I have a need to detect if an error is caused by HTTP error 404 in
Application_Error (in global.asax). I read MSDN docs but did not get an
answer.

Is there a reliable workaround to detect this status?
Nov 6 '08 #1
2 3405

"Edward" <ne***********@msn.comwrote in message
news:uO**************@TK2MSFTNGP02.phx.gbl...
>I have a need to detect if an error is caused by HTTP error 404 in
Application_Error (in global.asax). I read MSDN docs but did not get an
answer.

Is there a reliable workaround to detect this status?
404 Not Found is caught by IIS, not your webapplication. Your webapplication
will never get this error. What you could do is configure IIS to redirect to
a certain error page which your application could use to detect the 404.
Nov 6 '08 #2
Bresco wrote:
"Edward" <ne***********@msn.comwrote in message
news:uO**************@TK2MSFTNGP02.phx.gbl...
>I have a need to detect if an error is caused by HTTP error 404 in
Application_Error (in global.asax). I read MSDN docs but did not get an
answer.

Is there a reliable workaround to detect this status?

404 Not Found is caught by IIS, not your webapplication. Your webapplication
will never get this error. What you could do is configure IIS to redirect to
a certain error page which your application could use to detect the 404.

I can trap 404 error by <customErrorsin web.config. I have tested this
in IIS and it's working.

I find a way to check 404 in Application_Error:

File.Exists(this.Request.PhysicalPath);

But I am not sure if it is reliable.
Nov 6 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg Burns | last post by:
I am trying to write a global custom error page. I thought I would jot down some of what I've learned so far... At first I just used the default customErrors section with a defaultRedirect tag,...
3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
4
by: Michael | last post by:
Using some example code I've found, I'm trying to do the custom error page thing. I have the following in global.asax.. Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Dim...
2
by: Carl Johansen | last post by:
I've been reading the O'Reilly "ASP.NET Cookbook" 1st edition (Kittel and LeBlond), and it makes a recommendation about exception handling that seems a bit strange. They say that, if you want to...
6
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error...
1
by: David Herbst | last post by:
VS 2005 / .NET 2.0 Windows 2000 Server sp4 (on development as well as testing server) Using Web Deployment Project to build assemblies for testing and production servers. I added a Global.asax...
8
by: bmukulu | last post by:
Hi, I am trying to add some error handling in a Global.asax file. I am declaring a session variable within the Application_Error procedure. However, everytime i try to pass something into the...
2
by: =?Utf-8?B?QWxleCBNdW5r?= | last post by:
I am using VS2005 Professional, DOT.NET FrameWork 2. During testing and debugging through the IDE using the development machine LocalHost server whenever an error is encountered the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.