【问题标题】:The view 'Details' or its master was not found or no view engine supports the searched locations未找到视图“详细信息”或其主视图,或者没有视图引擎支持搜索到的位置
【发布时间】:2014-02-28 00:49:15
【问题描述】:

尝试在我的 mvc 5 网站上返回视图 @Html.ActionLink("Details", "Details", "Users", new { id = UserSearch.Id }, null) 时出现错误。

我不断收到错误消息 `

The view 'Details' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Users/Details.aspx
~/Views/Users/Details.ascx
~/Views/Shared/Details.aspx
~/Views/Shared/Details.ascx
~/Views/Users/Details.cshtml
~/Views/Users/Details.vbhtml
~/Views/Shared/Details.cshtml
~/Views/Shared/Details.vbhtml`

但是,类似的操作链接在我的网站上工作得很好。

任何帮助都会很棒。

用户控制器

public ActionResult Details(string Id)
        {
            if (Id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ApplicationUser user = db.Users.Find(Id);
            if (user == null)
            {
                return HttpNotFound();
            }
            return View(user);
        }

详情页

@model BiteWebsite.Models.ApplicationUser

@{
    ViewBag.Title = "Details";
}

<h2>Details</h2>


<div>
    <h4>Meal</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>
            @Html.DisplayNameFor(model => model.FirstName)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.FirstName)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.County)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.County)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Gender)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Gender)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.UserName)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.UserName)
        </dd>

    </dl>
</div>

已更新 用户模型

public class ApplicationUser : IdentityUser
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Email { get; set; }
        public string Gender { get; set; }
        public string HouseNumber { get; set; }
        public string StreetName { get; set; }
        public string County { get; set; }
        public string PostCode { get; set; }
        public string DateofBirth { get; set; }
        public virtual UserCuisineChoice UserCuisineChoice { get; set; }
    }

【问题讨论】:

  • 可以展示模型吗?
  • 我已经添加了用户模型
  • 您的详细信息页面所在的文件路径是什么?它的名称是什么?

标签: c# html asp.net razor asp.net-mvc-5


【解决方案1】:

我刚刚发现详细信息页面位于导致错误的错误文件夹中。感谢您的帮助

【讨论】:

    猜你喜欢
    • 2013-08-18
    • 2013-06-23
    • 2015-07-09
    • 2017-03-09
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多