ASP.Net MVC3 routing reserved words?

核能气质少年 提交于 2019-11-28 01:53:00

Yes, con is a reserved word and thus cannot be put in a MVC route. Here is a blog post describing a work-around:

http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx

And another post detailing the reasons behind the reserved words:

http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/

CON is a reserved word like COM1, COM2, COM3, COM4, LPT1, LPT2, AUX, PRN, NUL.

I also run into this problem while using ajax request. I solved by putting "-" char at the beginning of parameter, and then I replaced it in code-behind.

But it was a silly solution, you can solve this problem easily by simply adding

    <system.web>
        <httpRuntime relaxedUrlToFileSystemMapping="true"/>
         ......
    </system.web>

to your Web.config file and you can safely use these words in urls.

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