Ron*_*Ron 9 reserved-words asp.net-mvc-routing asp.net-mvc-3
我有一个ASP.Net MVC应用程序,其中定义了标准路由.该应用程序编辑我们数据库的元数据.网址方案是:
http://localhost/tables/Edit/[Name of Table Here]
Run Code Online (Sandbox Code Playgroud)
这将调用控制器edit上的函数tables并将表的名称作为参数传递id.除了一个名称之外,所有表都可以正常工作con.以下URL产生404:
http://localhost/tables/Edit/con
Run Code Online (Sandbox Code Playgroud)
我唯一能想到的是,con必须是关于MVC路由的某种保留字.有谁知道是否是这种情况,是否还有其他保留字要避免?
ali*_*ray 13
是的,con是一个保留字,因此不能放入MVC路由.这是一篇描述解决方法的博客文章:
http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
另外一篇文章详细说明了保留词背后的原因:
http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/