我正在创建asp.net web api,我正在尝试通过日期时间选择器在其中一个字段中添加日历控件。在我运行应用程序并按下创建文章/事件的按钮后,它显示以下错误: System.Web.HttpException:'已定义的部分:“脚本”。'
这是我的_Layout.cshtml
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Public Events</title>
@Styles.Render("~/Content/css")
@RenderSection("styles", required: false)
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Events", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@if (Request.IsAuthenticated)
{
<li>@Html.ActionLink("My Events", "My", "Events")</li>
<li>@Html.ActionLink("Create Event", "Create", "Events")</li>
}
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@Html.Partial("_Notifications")
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - Events Application</p>
</footer>
</div>
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
答案 0 :(得分:1)
脚本部分定义了两次。删除一个或组合它们。
@section scripts
{
//...
}