【问题标题】:Exception-User Unhandled / System.Web.HttpExceptionException-User Unhandled / System.Web.HttpException
【发布时间】:2018-02-23 10:24:11
【问题描述】:

我正在创建 asp.net web api,并尝试通过日期时间选择器在其中一个字段中添加日历控件。在我运行应用程序并按下创建文章/事件的按钮后,它显示此错误:System.Web.HttpException: 'Section already defined: "scripts".'

这是我的 _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>&copy; @DateTime.Now.Year - Events Application</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
    
</body>
</html>

【问题讨论】:

    标签: c# asp.net visual-studio render httpexception


    【解决方案1】:

    脚本部分定义了两次。删除或合并它们。

        @section scripts 
        { 
            //... 
        }
    

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 2013-10-04
      • 2021-06-04
      • 2012-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多