2016-06-08 55 views
0

我正在尝试做一些相当基本的工作,但似乎无法正常工作。 我有一个剃须刀页面,我在我的NewsSurfaceController中调用一个动作'索引'。在路径值中找不到Umbraco路由定义

@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")

我newscontroller:

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 
 
     }

当我去的网页,它让我看到正确的项目,但是当我点击ActionLink的,它抛出一个错误。

无法找到在路由值的一把umbraco路线定义,要求必须在一把umbraco请求

的情况下进行。当我调试,问题似乎是“当前页”对象。

在Umbraco.Web.Mvc.SurfaceController.get_CurrentPage() 在MyProject.Controllers.NewsSurfaceController.Archive()在C:\用户\托马斯\文件\的Visual Studio 2015 \项目\ MyProject的\控制器\ NewsSurfaceController .cs:line 25 at lambda_method(Closure,ControllerBase,Object []) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller,Object [] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary 2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary 2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod() 在System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult的asyncResult,ActionInvocation innerInvokeState) 在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.End() 在System.Web.Mvc.Async.AsyncResultWrapper。端[TResult](IAsyncResult的asyncResult,对象标签) 在System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult的asyncResult) 在System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() 在的System.Web .Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters。 <> c__DisplayClass46.b__3f()

我在做什么错? 任何人都可以指向正确的方向。

亲切的问候!

--------- --------编辑

好吧显然,这是一把umbraco的错误。 Issue on the umbraco forum

回答

0

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

+0

谢谢你的回应。我很抱歉,我应该把我的完整控制器代码放在我的帖子中。它从SurfaceController继承。 – Thomas