ASP.Net MVC3路由保留字? [英] ASP.Net MVC3 routing reserved words?

查看:288
本文介绍了ASP.Net MVC3路由保留字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有定义的标准路线的ASP.Net MVC应用程序。该应用程序编辑元数据为我们的数据库。 URL方案是:

I have an ASP.Net MVC application with the standard routes defined. The app edits meta data for our database. The url scheme is:

http://localhost/tables/Edit/[Name of Table Here]

这调用编辑在控制器函数,并将在表中的参数<名code> ID 。除了一个名为 CON 所有表的正常工作。下面的网址出现了404:

This calls the edit function on the tables controller and passes in the name of the table as the parameter id. All of the tables work fine except one named con. The following URL results in a 404:

http://localhost/tables/Edit/con

我能想到的唯一的事情就是 CON 必须是某种保留字相对于MVC路由。有谁知道这是否是这种情况,如果有其他的保留字来避免?

The only thing I can think of is that con must be some sort of reserved word with respect to MVC routing. Does anyone know whether this is the case and if there are other reserved words to avoid?

推荐答案

CON 是一个保留字,因此不能放在一个MVC路线。这里是一个博客帖子描述了一个变通办法:

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

<一个href=\"http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx\">http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx

和另一篇文章详细说明后面的保留字的原因:

And another post detailing the reasons behind the reserved words:

<一个href=\"http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/\">http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/

这篇关于ASP.Net MVC3路由保留字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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