Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm currently working on a website that represent multiple websites. For exemple: www.mychatsite.com and www.mijnberichtensite.nl. We have created a custom viewengine to use different views for both websites while we can re-use the website engine.

Because the first website is english and the second website is dutch we also needed to do some kind of URL rewriting. So in the RegisterRoutes (in global.asax) I added some routes to do my url customization. When you goto "www.mijnberichtensite.nl/aanmelden" you'll actually request the controller "signup/index".

C#
routes.MapRoute(
          "aanmelden",
          "/aanmelden",
          new { controller = "signup", action = "index" }
     );


This all works well, but now there are some problems:

1. When you are on the Dutch website and you request the English url, it will work as well. (which would be a nice to have if we could solve this)
2. MVC's UrlHelper is mixing the urls, when you do BeginForm("index", "signup"), you will be redirected to the url: "/aanmelden" because it is first in the routing table prior to the original routing. This is good behaviour for the dutch website, but not for the english website.

While I was searching for the solution online I found alot of different takes on this problem, but nobody wants to use totally different urls (only rewriting like: /nl/signup/index). So I couldn't find an example of the correct take on this problem.

What would be the best way to solve this?

Best regards,

Willem
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900