473,397 Members | 1,949 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,397 software developers and data experts.

Getting URL that caused 404 error

If I go into IIS and change the default 404 error page to an ASPX page, is there any way to then identify the url that was typed in that caused the custom 404 page to be loaded? If so, how do I do that (C# prefered)?

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 3 '06 #1
6 2206
Isn't the original URL appended in the querystring?

Cheers
Ken
"Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_comwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...
If I go into IIS and change the default 404 error page to an ASPX page, is
there any way to then identify the url that was typed in that caused the
custom 404 page to be loaded? If so, how do I do that (C# prefered)?

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )

Oct 3 '06 #2
If you are using the web.config error redirecting, you get a partial url listed in the query string under aspxerrorpath=/path (except that if in this case all the original query string parameters are lopped off and you only get the path to the page -- not as useful as it could be).

In my case, I'm referring to going into the IIS settings and modifying the pointer to the default 404 error page to a custom page. In this case the browser address well still shows the address that cased the 404 error (as it was typed in or navigated to), but the custom 404 page displays. No modification is made to the url.

It is in this latter case that I want to be able to identify the url in the address well that was sent to my custom 404 page (again this is from an IIS modification, not a web.config setting).

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 3 '06 #3
Hi,

Check both the Querystring and the current page name. Depending on whether
the file was handler by the IIS Static File Handler, or handled by an ISAPI
filter, you will see different results in the browser's address bar. This is
a function of whether IIS is internally using something akin to
Server.Execute to transfer across to the 404 page, or is using something
akin to Response.Redirect() to transfer across to the 404 page.

Cheers
Ken
"Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_comwrote in message
news:e1**************@TK2MSFTNGP04.phx.gbl...
If you are using the web.config error redirecting, you get a partial url
listed in the query string under aspxerrorpath=/path (except that if in this
case all the original query string parameters are lopped off and you only
get the path to the page -- not as useful as it could be).

In my case, I'm referring to going into the IIS settings and modifying the
pointer to the default 404 error page to a custom page. In this case the
browser address well still shows the address that cased the 404 error (as it
was typed in or navigated to), but the custom 404 page displays. No
modification is made to the url.

It is in this latter case that I want to be able to identify the url in the
address well that was sent to my custom 404 page (again this is from an IIS
modification, not a web.config setting).

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )

Oct 4 '06 #4
Interesting. . . you are right on that. Even though you don't see a query string, there's one there in the format of:

404;http://localhost:80/path_you_typed

This query string is encoded--so it must be decoded first to be useful. I also note that it added the port ":80" to the host name.

But this is sufficient to get me what I need.

Thanks.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 5 '06 #5

Greg Collins [Microsoft MVP] wrote:
Interesting. . . you are right on that. Even though you don't see a query string, there's one there in the format of:

404;http://localhost:80/path_you_typed

This query string is encoded--so it must be decoded first to be useful. I also note that it added the port ":80" to the host name.

But this is sufficient to get me what I need.
You need to be a little careful with how you interpret the string. If
the URL is all plain ASCII characters then it should be sufficient, but
there are some edge conditions that may be relevant:

http://www.kirit.com/Errors%20in%20I...ror%20handling
Kirit

Oct 6 '06 #6
So is the question mark character the only character I need to be worried about?
Thanks.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 7 '06 #7

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

Similar topics

15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
3
by: Larry Tate | last post by:
I have had a monstrous time getting any good debugging info out of the .net platform. Using ... ..NET Framework 1.1 Windows 2K Server VB.NET <- is this the problem? error handling in the...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
2
by: darrel | last post by:
I have a question below about an error I am getting: Exception has been thrown by the target of an invocation. Is there anyway to get asp.net to give me more details than the above? My catch...
0
by: maheshwari.sumit | last post by:
Hi, I am getting error Error: File /default/default.asp CreateObject Exception. The CreateObject of '(null)' caused exception C0000005, when i trying to create an object of component. This...
0
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
1
by: viswanathtvs | last post by:
java.util.NoSuchElementException javax.faces.el.EvaluationException: java.util.NoSuchElementException at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.