繁体   English   中英

在路线值中找不到Umbraco路线定义

[英]Cannot find the Umbraco route definition in the route values

我正在尝试做一些相当基本的事情,但是它似乎没有用。 我有一个剃须刀页面,在这里我的NewsSurfaceController中将动作称为“索引”。

 @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "Master.cshtml"; } <div class="row"> <h1 class="col-xs-12 col-sm-4">@CurrentPage.Name</h1> <div class="col-xs-12 col-sm-2 col-sm-offset-4 "> @Html.ActionLink("Archief", "Archive", "NewsSurface", null, new { @class = "content-link-button-reverse" }) </div> </div> @Html.Action("Index", "NewsSurface") 

我的新闻控制器:

public class NewsSurfaceController : SurfaceController
{
    private int itemsPerpage= 4;

    public ActionResult Index()
    {
        return PartialView("newslist", new NewsRepo(CurrentPage).items.Take(itemsPerpage));
    }

    public ActionResult Archive()
    {
       return PartialView("newslist", new NewsRepo(CurrentPage).archivedItems.Take(itemsPerpage));
    }

}

这将返回只迭代项目的局部视图。

 @inherits Umbraco.Web.Mvc.UmbracoViewPage<MyProject.models.NewsItemViewModel> @foreach (MyProject.models.NewsItem item in Model) { //displays the properties } 

当我转到页面时,它可以正确显示项目,但是当我单击操作链接时,它将引发错误。

在路由值中找不到Umbraco路由定义,该请求必须在Umbraco请求的上下文中进行

当我调试时,问题似乎出在“ CurrentPage”对象上。

在Umbraco.Web.Mvc.SurfaceController.get_CurrentPage()在MyProject.Controllers.NewsSurfaceController.Archive()在C:\\ Users \\ thomas \\ Documents \\ Visual Studio 2015 \\ Projects \\ MyProject \\ Controllers \\ NewsSurfaceController.cs:第25行在lambda_method (在System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,Object []参数)在System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary 2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary (闭包,ControllerBase,Object []) 2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary 2参数)在System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase innerInvokeState)2.System.Web.Mvc.Asyn处的2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.End()(位于System.Web.Mvc.Async.AsyncResultWrapper.End [TResult](IAsyncResult asyncResult,Object tag)位于System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) .Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d()在System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters。<> c__DisplayClass46.b__3f()

我究竟做错了什么? 谁能指出我正确的方向。

亲切的问候!

- - - - -编辑 - - - -

好的,显然这是Umbraco中的错误。 在umbraco论坛上发布

您的控制器继承自SurfaceController吗? 否则,该路线将不会为您注册。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM