导航到ASP.NET MVC 4中另一个控制器的索引视图

时间:2013-06-09 03:10:55

标签: asp.net-mvc-4

我在指数 主页控制器的视图。

我使用默认的索引操作方法创建了一个名为 EstimationTracker 的控制器。我还创建了 EstimationTracker 索引视图。但是, EstimationTracker 控制器的索引操作方法中没有任何内容。

现在,我想在 HomeController 索引视图中创建 Html.ActionLink ,以导航至索引视图 EstimationTracker 控制器。

我已编写以下代码来实现此目的:

@Html.ActionLink("Estimation Tracker", "Index", "EstimationTracker", null, new { })

在浏览器中,如果我点击“Estimation Tracker”超链接,该页面将生成以下网址:

http://localhost:8416/EstimationTracker/

并弹出以下错误:

HTTP错误403.14 - 禁止

Web服务器配置为不列出此目录的内容。

当我将索引附加到上述网址时:

http://localhost:8416/EstimationTracker/Index

现在,页面很好。

如何让页面顺利运行而不会出现任何错误。

更新

我只使用默认路由。如下所示

        public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }

0 个答案:

没有答案