c# – 未找到路径’/’的控制器或未在Sitecore中实现IController
发布时间:2020-12-15 04:32:01 所属栏目:百科 来源:网络整理
导读:我正在从 Here学习Sitecore中的Controller渲染. 我创建了一个简单的控制器(HelloWorld)和相关视图(Index.schtml).在Sitecore Explorer的渲染部分中映射它(使用Name PageContent)…并在Sitecore Explorer的内容部分中的Home Item中添加渲染项目.但是当我浏览
我正在从
Here学习Sitecore中的Controller渲染.
我创建了一个简单的控制器(HelloWorld)和相关视图(Index.schtml).在Sitecore Explorer的渲染部分中映射它(使用Name PageContent)…并在Sitecore Explorer的内容部分中的Home Item中添加渲染项目.但是当我浏览它时,它会给出错误. The controller for path '/' was not found or does not implement IController. 我读过的所有帖子都与Asp .Net MVC相关..但我有与Sitecore MVC相关的问题 Sample.html(Sitecore Explorer渲染部分中的页面内容) @using Sitecore.Mvc <html> <body> @Html.Sitecore().Placeholder("content") <p>Today's date is @DateTime.Now.ToShortDateString()</p> </body> </html> 只有这条线给出了问题 @Html.Sitecore().Placeholder("content") 如果我删除此行…它工作正常,浏览器上的页面显示日期和时间 的index.html <p>Hello from Controller -todays Date is @DateTime.Now.ToString()</p> 调节器 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MVC.Controllers { public class HelloWorldController : Controller { // // GET: /HellowWorld/ public ActionResult Index() { return View(); } } } 解决方法
如果您已包含默认MVC路由,则会发生这种情况,因为它们会覆盖Sitecore自己的控制器实现.
确保您已从RouteConfig.cs / Global.cs中删除以下行(取决于MVC版本); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home",action = "Index",id = UrlParameter.Optional } ); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |