【问题标题】:showing non Umbraco View, error "HTTP Error 404.0 - Not Found"显示非 Umbraco 视图,错误“HTTP 错误 404.0 - 未找到”
【发布时间】:2014-09-15 06:32:21
【问题描述】:

在 MVC 4 应用程序中,我有 Nuget Umbraco CMS 7。

我需要保留一个非 Umbraco/自定义控制器的视图。我创建了一个名为 Users 的 MVC 控制器,它有一个名为 Index 的操作。我在 web.config 中更新了umbracoReservedUrls 如下:

<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,~/Users/Index" />

以下是我的控制器代码:

 public class UsersController : Controller
    {
        //
        // GET: /Users/

        public ActionResult Index(User model)
        {
            return View(model);
        }

    }

我的视图标记如下:

@model Common.Model.User

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

问题: 在运行时,如果我导航到 http://localhost:56512/users/index,控制不会到达控制器,并且在浏览器中出现 404 错误,详情如下:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

您能否指导如何解决此问题并导航到非 Umbraco 视图和控制器?

【问题讨论】:

    标签: .net asp.net-mvc-4 umbraco umbraco7 umbraco-mvc


    【解决方案1】:

    将控制器路径放入umbracoReservedPaths而不是UmbracoReservedUrls

    或者考虑将您的控制器包装在 RenderMvcController、表面控制器、局部视图中......

    【讨论】:

    • 谢谢@dampee,我的控制器“UsersController”在默认的controlelrs文件夹中,视图“索引”在视图/用户/索引中。你能指导我应该如何配置它吗?和我上面说的一样吗?
    • 我的控制器位于默认控制器文件夹中。我做了 但它没有用。
    • 你确定你的控制器已经编译了吗?如果您使用的是网站(例如在 webmatrix 中),则将其移至 App_Code 会更容易。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    • 2020-04-30
    • 1970-01-01
    • 2011-04-01
    相关资源
    最近更新 更多