ASP.NET MVC Url Route 支持(点) [英] ASP.NET MVC Url Route supporting (dot)
问题描述
希望您能帮我解决以下问题.
I hope that you can help me with the below problem.
我在 IIS7 上使用 ASP.NET MVC 3,并希望我的应用程序支持带点的用户名.
I am using ASP.NET MVC 3 on IIS7 and would like my application to support username's with dots.
这是我的 Global.asax 的样子:(http://localhost/{username})
This is how my Global.asax looks like: (http://localhost/{username})
routes.MapRoute(
"UserList",
"{username}",
new { controller = "Home", action = "ListAll" }
);
当我访问其他页面(例如 http://localhost/john.lee/details 等等
The applications works when I access other pages such as http://localhost/john.lee/details etc.
但是主用户页面不起作用,我希望应用程序像 Facebook 一样工作,其中 http://www.facebook.com/john.lee 支持.
But the main user page doesn't work, I would like the app to work like Facebook where http://www.facebook.com/john.lee is supported.
我使用了下面的代码,但它根本不适合我:
I used below code and it didn't work for me at all:
<httpRuntime relaxedUrlToFileSystemMapping="true" />
我能够使用下面的代码并让应用接受点,但由于许多不同的原因我绝对不喜欢使用下面的代码,请告诉我有一种方法可以解决这个问题.
I was able to use below code and get the app to accept dots but I definitely wouldn't like to use below code for many different reason, please tell me there is a way to overcome this problem.
<modules runAllManagedModulesForAllRequests="false" />
推荐答案
我遇到了同样的问题.所以对我来说最好的解决方案是:
I was facing the same issue. So the best solution for me is:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"></modules>
<system.webServer>
这篇关于ASP.NET MVC Url Route 支持(点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!