开发者

Redirecting to force parameter in url (MVC)

开发者 https://www.devze.com 2022-12-20 07:31 出处:网络
I am working on a multilingual website where the URL will contain the language code: /en/Home /es/Home Whenever someone enters a url that does not have the language code at the beginning (/Home), I

I am working on a multilingual website where the URL will contain the language code:

/en/Home

/es/Home

Whenever someone enters a url that does not have the language code at the beginning (/Home), I would like to do a 301 redirect to the url (route) they entered but append the language code at the begin开发者_Python百科ning. I will determine the language to redirect to based on the language setting of their browser (HttpContext.Request.UserLanguages).

Since I will have logic within MVC, I cannot use the IIS7 URL rewriting.

I am not sure if it would be best to create a custom HttpHandler or RouteHandler or something else.


Check out this blog for a way to handle localization in ASP.NET MVC: http://helios.ca/2009/05/27/aspnet-mvc-and-localization/

Not what you were asking for specifically but an interesting approach.

0

精彩评论

暂无评论...
验证码 换一张
取 消