我整天都在遭受这些问题,我无法弄清楚出了什么问题 我在我的事件/创建视图中有这些代码
@model UpdatedForum.Models.Event
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm("Create", "Events", FormMethod.Post, new {enctype="multipart/form-data" }))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Event</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Image, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="file" name="imageinput" id="someid" accept=".jpg,.png,.jpeg,.gif" />
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model=>model.Description);
@Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Date, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section scripts {
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Content/ckfinder/ckfinder.js"></script>
<script src="~/Content/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
var editor = CKEDITOR.instances['Description'];
if (editor) { editor.destroy(true); }
CKEDITOR.replace('Description', {
enterMode: CKEDITOR.ENTER_BR,
});
CKFinder.setupCKEditor(null, '@Url.Content("~/Content/ckfinder")');
</script>
}
我的_Layout.cshtml视图的代码是
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CNET Forum</title>
<!-- Bootstrap core CSS -->
<link href="~/Content/production/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/production/fonts/css/font-awesome.min.css" rel="stylesheet" />
<link href="~/Content/production/css/animate.min.css" rel="stylesheet" />
<!-- Custom styling plus plugins -->
<link href="~/Content/production/css/custom.css" rel="stylesheet" />
<link href="~/Content/production/css/icheck/flat/green.css" rel="stylesheet" />
<script src="~/Content/production/js/jquery.min.js"></script>
</head>
<div class="row">
@RenderBody()
</div>
<script src="~/Content/production/js/progressbar/bootstrap- progressbar.min.js"></script>
<script src="~/Content/production/js/nicescroll/jquery.nicescroll.min.js"></script>
<!-- icheck -->
<script src="~/Content/production/js/icheck/icheck.min.js"></script>
<script src="~/Content/production/js/custom.js"></script>
<!-- pace -->
<script src="~/Content/production/js/pace/pace.min.js"></script>
</body>
</html>
我得到的错误是
>应用程序中的服务器错误。以下部分已定义,但尚未针对布局页面“〜/ Views / Shared / _Layout.cshtml”:“scripts”进行渲染。
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Web.HttpException:已定义以下部分但尚未为布局页面“〜/ Views / Shared / _Layout.cshtml”:“scripts”呈现。