I don't think you're right.
If you typed in p5gdls.aspx, then you get to find out the invalid url, but
if you type in plain p5gdls then IIS (as standard configuration) doesn't
pass onto the 404 page the originally requested url.
To help the user in this case (and where you can't configure IIS so that
ASP.NET handles all file extentions, including none) you should put a link
to your search page on your 404.
Of course, if you have access to configure IIS then you can take the
original request, pattern match for similar product IDs and present a list
of alternatives a la "Did you mean......".
"Grant Merwitz" <gr***@workshare.com> wrote in message
news:uk**************@TK2MSFTNGP10.phx.gbl...
yeah, request.url should pickup what the attempted url was.
you can then strip of the "http:\\xxxxxxxx.com\" to get your product id,
and check if thats an existing product.
then redirect the user accordingly
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl... ABC wrote: If I has a web site which contains follows maps:
\default.aspx
\search.aspx
\products.aspx
\contacts.aspx
I should want to handle the unknow URL redirect to search.aspx to
search. For example, users enters the path as:
http:\\xxxxxxxx.com\P5GDLS
In my mind, P5GDLS is one of our products. When user entered above,
I want it redirect to search.aspx to search P5GDLS product
information. I don't this case naming, but I know some web sites can
handle. How should I to write the code to handle this case.
You can't handle it completly within asp.net. As P5GDLS is not
recognised by IIS as something that should be handled by asp.net, that is never
aware of this request.
However, IIS itself will see that there is no file or directory with
that name.
The usual result is a "404" warning, but you can instruct IIS to show a
specific page instead. So you could redirect "unknown page" errors
to a specific page within your application. If I'm not mistaken, you
will get the failed url as parameter, so then it's up to you to try and do
something with that.
Hans Kesting