Add Friendly URLs to Multi lingual ASP.NET website, without using MVC

不打扰是莪最后的温柔 提交于 2019-12-12 06:44:14

问题


I have a project developed in ASP.NET webforms, the project has content in 2 different languages which can be selected from a dropdownlist, that project is available for download from the following link: http://www.mediafire.com/download/4d7dbdthh2094s6/test-idiomas-urls.rar I need that when I select any of the languages, the URL change from this: example.com/Default.aspx to this: example.com/en/home or example.com/es/home. I have excluded ASP.NET MVC. How could I make that work?


回答1:


Including Default.aspx isn't friendly. That's a pain to type, and it's not good for SEO. You can use MapPageRoute to do your routing.

routes.MapPageRoute("","en", "~/English/Default.aspx");
routes.MapPageRoute("","sp", "~/Spanish/Default.aspx");
routes.MapPageRoute("","en/Contact", "~/English/Contact.aspx");
routes.MapPageRoute("","sp/Contact", "~/Spanish/Contact.aspx");

But I really hope you don't actually use different pages for each language? Probably better to use one page and then pass route values or use cookies for getting/setting the language.



来源:https://stackoverflow.com/questions/29679999/add-friendly-urls-to-multi-lingual-asp-net-website-without-using-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!