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

How to automatic redirect the wrong URL to the specific page?

ABC
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.
Nov 19 '05 #1
3 3339
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
Nov 19 '05 #2
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

Nov 19 '05 #3
KMA
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


Nov 19 '05 #4

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

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
4
by: Alistair | last post by:
IIS, Access 2000 I have a page that tabulates data from a DB, this data is items for sale, private ads. is there a way that at the same time it can automatically delete entries that are...
9
by: dm4714 | last post by:
Hello - we have an ecommerce application that needs to come down for maintenance. The application is normally only accessed via http://www.mydomain.com/virtualdir/aspfile.asp. I'm using W2K...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
1
by: JoanneC | last post by:
How can I incorporate the following javascript code in an ASP.NET application (using VB.NET) Like the following If textbox1.text = "" then <SCRIPT LANGUAGE="JavaScript" runat="server">...
0
by: Laura K | last post by:
I know this is basic but I just can not get my head around it. I would like to take a querystring and from that querystring redirect the user to a specific page. I set up a simple test and I am...
2
by: Jan Paul van de Berg | last post by:
I have a piece of software that people can download and a third party promoting that software. In order for them to be able to count the number of downloads, I have to put a tracking code on my...
1
by: Siva | last post by:
Hi, Can somebody help me in getting me a code for automatic redirection. I have a message box in my project. If somebody post a message, after clicking the submit button a thankyou.aspx page...
8
pentahari
by: pentahari | last post by:
Redirect to login page if session("UserName") is expired when the page useraccount.aspx load event My useraccount.aspx code : If Session("UserName") Is Nothing Then ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.