【问题标题】:N2 CMS and MVC 3 RC causes "The current request for action 'Index' on controller...is ambiguous...'N2 CMS 和 MVC 3 RC 导致“控制器上当前对操作 'Index' 的请求......不明确......”
【发布时间】:2011-01-13 09:16:17
【问题描述】:

我已经使用 N2 CMS 一段时间了,我刚刚更新为使用 MVC 3 RC,现在我在每个页面上都收到此错误:

当前对操作“索引”的请求 在控制器类型“HomeController”上是 以下动作之间模棱两可 方法:System.Web.Mvc.ActionResult 类型上的索引() Project.Web.Controllers.N2Controller1[[Project.Web.Models.HomePage, Project.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] System.Web.Mvc.ActionResult Index() on type N2.Web.Mvc.ContentController1[[Project.Web.Models.HomePage, Project.Web,版本=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

只是为了说明我有一个 HomeController,它继承自 N2Controller,N2Controller 继承自 N2.Web.Mvc.ContentController

每个控制器、Home、Account 等都没有 Index 方法,因为 ContentController 已经有一个。

这一切在 MVC 2 上运行得非常好,但在 MVC 3 RC 上却抛出了这个错误。

有什么想法吗?我在网上找不到任何东西...

干杯, 灰烬。

【问题讨论】:

    标签: asp.net-mvc content-management-system asp.net-mvc-3 n2 n2cms


    【解决方案1】:

    这听起来像 N2Controller 有一个 Index 方法,应该在 ContentController 中设置为 override Index 方法。

    在控制器上解析操作方法的方式必须在 MVC2 和 3 之间发生变化,以考虑继承层次结构,从而导致此问题。

    【讨论】:

    • 我重写了 Index 方法,但我删除了它并且它起作用了....我没有提到我在 Azure 开发结构中运行它,Razor 花了很长时间才开始在 Azure 上工作也!
    猜你喜欢
    • 2013-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 1970-01-01
    • 1970-01-01
    • 2017-07-05
    • 1970-01-01
    相关资源
    最近更新 更多