ASP.NET MVC路由与一个名为&QUOT控制器; PropertiesController" [英] ASP.NET MVC Routing with a controller named "PropertiesController"

查看:130
本文介绍了ASP.NET MVC路由与一个名为&QUOT控制器; PropertiesController"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个棘手的问题(承担与我,因为我是新来的MVC),试图与名称PropertiesController使用控制器(以及随后的路由)。

I'm having a tricky issue (bear with me as I'm new to MVC) with trying to use a controller (and a route subsequently) with the name PropertiesController.

我相信这是因为有一个目录(我真的不能删除)在我的解决方案叫做属性。是否有办法解决这?

I believe this is because there is a directory (which I can't really remove) called "Properties" in my solution. Is there a way round this?

这条路线的设置只是一个简单的路线:

The route setup is just one simple route:

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Properties", action = "List", id = "" } // Parameter defaults 
);

和错误我请求时,得到IIS7的http://本地主机/ aptment2 /属性/ 是:

and the error I get in IIS7 when requesting "http://localhost/aptment2/properties/" is:

当然是有办法解决这,我只是找不到?干杯。

Surely there is a way round this that I just can't find? Cheers.

推荐答案

由于是别人有同样的问题,我猜你正在运行到一个保留关​​键字这里(我想象ClassControllers都出来为好)。

Since someone else is having the same problem, I'm guessing that you're running into a reserved keyword here (I imagine ClassControllers are out as well).

这不是第一次发生的事情或者 - 更深的挖掘到环境中,<一的内部href=\"http://stackoverflow.com/questions/987105/asp-net-mvc-routing-vs-reserved-filenames-in-windows\">you可以到Windows的保留关键字不是没有途径。

It's not the first time it's happened either - digging deeper into the internals of the environment, you can't route to Windows' reserved keywords either.

这篇关于ASP.NET MVC路由与一个名为&QUOT控制器; PropertiesController&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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