How can I get this url?

  • Thread starter Thread starter Jason Zhou
  • Start date Start date
In IE browser, if you type in http://www.microsoft.com/MyTestPage.asp,
definitely it is an invalid url, I noticed that I will come to this url
instead:
http://www.microsoft.com/info/smart404.asp?404;http://www.microsoft.com/MyTe
stPage.asp.

My question is: how can the iis get the wrong url
(http://www.microsoft.com/MyTestPage.asp) and pass it to another url as a
parameter?

Thanks!

Jason

a custom error page. if you look at your web site properties see the
custom errors section. Write your own error page to do what u want.

capture page urls / send out emails / update logs

whatever u want

-Adam
 
I did my own error page, but how can I capature that wrong url then?

Thanks!

Jason

Hello,

I gave it a try myself and I found that

HttpContext.Current.Request.RawUrl in the error page returns this:
"/errormessagre/webform1.aspx?404;http://localhost/blah"

I assume that if u take everything right fo the 404; you should get
u're url.

-Adam
 
Really? I tried this before but seems did not work. I will try it again
then.

Thank you very much for the help!

Jason
 
Adam,

Sorry, one more question.

From your sample, looks like in your one aspx page, you tried to call
http://localhost/blah, and this error was caught by webform1.aspx, and you
got this error message in your original aspx page. I am wondering in this
webform1.aspx instead of your original aspx page, can you get
http://localhost/blah this information?

Thanks!

Jason
 
From your sample, looks like in your one aspx page, you tried to call
http://localhost/blah, and this error was caught by webform1.aspx, and you
got this error message in your original aspx page.

I setup the webform1.aspx as the handler for error 404's within IIS.
The original web page does not exist and therefore can't handle
anything. If the error happens inside the scope of a configured
application then you will be able to handle it with its own 404
handler.

The problem is that if a 404 happens it is because the page doesn't
exist. You can do anything you want with this information.

-Adam
 
Back
Top