2

if the user type

http://myweb/mysite.aspx (file does not exist)

I want them to go to

http://myweb/site.aspx (file does exist)

My goal is to make a bilingual website (including url) but without having to make physical file

this would be one file

http://myweb/acceuil.aspx
http://myweb/home.aspx
2
  • stackoverflow.com/questions/1440883/… Commented Sep 24, 2009 at 19:31
  • Are you looking for all requested pages which don't exist to go to site.aspx or only mysite.aspx? Commented Sep 25, 2009 at 12:01

3 Answers 3

3

Not sure what you are trying to do, but this is the best turtorial for the question you asked:

How to: Use Routing with Web Forms

Sign up to request clarification or add additional context in comments.

2 Comments

Does this require the presence of the old page? If so, adding a simple script to the page solves that problem without a CustomRouteHandler. I think what he wants is a way to specify the old and new pages by name, without having to leave the old pages on the server.
I used the first url, "How to: Use Routing with Web Forms". You can remove everything else under it if you want. thanks
1

That's not routing; that is a redirect.

_rick_shott seems to have the mojo on routing bad urls into a 301 redirect. I upvoted his answer. You should check out his HTTPModule solution.

3 Comments

with redirect, you have to create a file, I want to use the routing module so I wont have o do that
Do you care about search engine optimization?
@Fredou: You don't have to create a file if you use an HTTPModule
0

In your web.config, add a customErrors and error node as follows:

    <customErrors mode="On" defaultRedirect="ErrorDisplayPage.aspx">
     <error statusCode="404" redirect="http://myweb/site.aspx"/>
    </customErrors>

This will displayErrorDisplayPage.aspx for all unmanaged errors except for 404 errors (which are "page not found"). For 404 errors, the browser will redirect to the site.aspx page.

2 Comments

AFAIK this will redirect ALL 404's to the new page, unless this is in a location element. See msdn.microsoft.com/en-us/library/b6x6shw7(VS.71).aspx for more info.
Sorry, I thought that is what the poster was asking for - all not found pages to go to site.aspx.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.