文章内容

2017/3/14 10:36:46,作 者: 黄兵

未找到路径“xxxx”的控制器或该控制器未实现 IController

在使用ASP.NET MVC 5 area的时候,参照ASP.NET MVC5使用Area区域,使用功能模块清晰明了增加了相应的页面,如图所示:

使用模板页,代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title - 梵媞医学美容</title>
    @Styles.Render("~/Content/BrandCenter","~/Content/customer/Case-liku.css")
    @RenderSection("css",required:false)
</head>
<body>
    @Html.Action("_Common_Head""BrandCenter")
    <div>
        @RenderBody()
    </div>
    @Html.Action("_Common_Foot""BrandCenter"new { area=""})
    @Scripts.Render("~/bundles/jquery""~/bundles/BrandCenter")
    @RenderSection("script",required:false)
</body>
</html>

这个模板页在这里(Home/View/Share下面),截图如下:


运行之后报了下面错误:

未找到路径“/Topics/Alopecia/index”的控制器或该控制器未实现 IController。

解决方案:

2、不同Area之间跳转

  1. @Html.ActionLink("Click me to go to another area", "Index", new { area = "Support" })

3、跳转到不是带Area的Action

  1. 我们知道使用Html.ActionLink没有指定area,默认就是当前的area。有时我们需要链接到顶层的Controller的Action,就是不要带area,也很简单,只需要把area传空字符串就可以了。如下:

    1. @Html.ActionLink("Click me to go to another area", "Index", new { area = "" })

修改源代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title - 梵媞医学美容</title>
    @Styles.Render("~/Content/BrandCenter","~/Content/customer/Case-liku.css")
    @RenderSection("css",required:false)
</head>
<body>
    @Html.Action("_Common_Head""BrandCenter"new { area = "" })
    <div>
        @RenderBody()
    </div>
    @Html.Action("_Common_Foot""BrandCenter"new { area=""})
    @Scripts.Render("~/bundles/jquery""~/bundles/BrandCenter")
    @RenderSection("script",required:false)
</body>
</html>
分享到:

发表评论

评论列表