尝试在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; }
}
答案 0 :(得分:0)
我刚刚发现详细信息页面位于导致错误的错误文件夹中。谢谢你的帮助