Search code examples
asp.netasp.net-mvc-3iis-7url-routingglobal-asax

ASP.NET MVC Url Route supporting (dot)


I hope that you can help me with the below problem.

I am using ASP.NET MVC 3 on IIS7 and would like my application to support username's with dots.

Example: http://localhost/john.lee

This is how my Global.asax looks like: (http://localhost/{username})

routes.MapRoute(
    "UserList",
    "{username}",
    new { controller = "Home", action = "ListAll" }
);

The applications works when I access other pages such as http://localhost/john.lee/details etc.

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" />

Solution

  • I was facing the same issue. So the best solution for me is:

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"></modules>
    <system.webServer>