asp.net-mvc - Umbraco 表面 Controller 未正确路由

标签 asp.net-mvc asp.net-mvc-4 model-view-controller umbraco7 umbraco6

我在让表面 Controller 正确启动时遇到了一些麻烦。

public class SocialShareSurfaceController : Umbraco.Web.Mvc.SurfaceController
{
    public ActionResult Index()
    {
        return Content("hello world");
    }
}

我正在尝试通过以下 URL 访问 Controller :http://website.local/umbraco/surface/SocialShare/Index/

但是我收到 404 错误...如果我随后将此文件移动到 App_Code 文件夹,转到相同的 URL,我会收到此错误

名为“umbraco-surface-SocialShareSurface”的路线已在路线集合中。路由名称必须是唯一的。参数名称:名称

任何想法...

最佳答案

如果您像上面那样命名 Surface Controller (名称中包含“Surface”),那么您的路线还需要在 Controller 名称中包含 Surface:

http://website.local/umbraco/surface/SocialShareSurface/Index/

您可以直接调用 Surface Controller 类 SocialShareController - 根本不需要在类名称中包含 Surface 关键字。

关于asp.net-mvc - Umbraco 表面 Controller 未正确路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32843982/

相关文章:

java - 触发 Java GUI 更新

asp.net-mvc - MVC ELMAH 和 SQL Azure

javascript - 向 AJAX 请求返回一个空字符串

asp.net-mvc-4 - MVC 4 中的自定义授权和角色不起作用

asp.net-mvc-4 - ClaimsAuthorizationManager.CheckAccess : Handling false without going to login page

java - MVC模型中AbstractAction的实现

java - 除了Tomcat + Servlet之外,如何在不使用任何框架的情况下实现关注点分离?

c# - ASP.NET MVC 的新手,在处理包含表单的呈现操作时遇到问题

jquery - 在asp.net mvc中使用ajax发送Json数据数组和图像文件

c# - MSBuild with Azure - PublishProfileSet 的计算结果为 ""