【发布时间】:2017-01-16 23:17:31
【问题描述】:
我正在使用以下代码生成链接
@Html.ActionLink("Search", "Index", "Properties")
在客户端渲染
<a href="/Properties">Search</a>
查看上面的链接,我预计会到达
controller: Properties
action: Index
当我点击链接时,我被导航到http://localhost:49878/Properties/,我得到了错误
HTTP 错误 403.14 - 禁止 Web 服务器配置为不列出此目录的内容。
如果我导航到http://localhost:49878/Properties/Index,我会得到预期的页面。
为什么?
我查看了RouteConfig 以尝试理解这一点并查看默认路线
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
我以为下面的方法可以解决问题,但没有,为什么?
routes.MapRoute(
name: "Search",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Properties", action = "Index", id = UrlParameter.Optional }
);
【问题讨论】:
-
您的解决方案中是否有一个名为
Properties的文件夹? -
不,但我确实有一个名为 properties 的控制器
-
你确定? (默认情况下 VS 会创建一个)。如果你没有导航到(比如)
.../Content,你会得到同样的错误
标签: asp.net asp.net-mvc asp.net-mvc-4 razor html-helper