在不使用MVC的情况下将友好的URL添加到多语言ASP.NET网站 [英] Add Friendly URLs to Multi lingual ASP.NET website, without using MVC

查看:79
本文介绍了在不使用MVC的情况下将友好的URL添加到多语言ASP.NET网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ASP.NET Webforms开发的项目,该项目具有2种不同语言的内容,可以从下拉列表中选择内容,该项目可以从以下链接下载:

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?

推荐答案

包含Default.aspx并不友好.键入很麻烦,而且对SEO不利.您可以使用 MapPageRoute 进行路由.

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");

但是我真的希望您实际上不会为每种语言使用不同的页面吗?使用一页然后传递路线值或使用cookie来获取/设置语言可能更好.

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.

这篇关于在不使用MVC的情况下将友好的URL添加到多语言ASP.NET网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆