' /'中的服务器错误应用。 Asp.net Mvc4

时间:2016-09-20 05:19:43

标签: asp.net-mvc-4 razor

您好我开始使用asp.net mvc4bootstrap学习网络编程语言。运行我的应用程序时出现此错误(Server Error in '/' Application),但如果它是默认代码,则表示运行正常。

这些是我的代码

_ViewStart.cshtml

@{
Layout = "~/Views/Shared/_Layout.cshtml";
}

我没有在这里做任何改变

_Layout.cshtml

    <!DOCTYPE html>
<html lang="en">
    <head>
       <meta charset="utf-8" content="" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="Corinthians 3" />

        <title>Sample BS</title>
   <!-- Bootstrap Core CSS -->
    <link href="@Url.Content("~/plugin/bower_components/bootstrap/dist/css/bootstrap.min.css")" rel="stylesheet" type="text/css" />

    <!-- MetisMenu CSS -->
    <link href="@Url.Content("~/plugin/bower_components/metisMenu/dist/metisMenu.min.css")" rel="stylesheet" type="text/css" />

    <!-- DataTables CSS -->
    <link href="@Url.Content("~/plugin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css")" rel="stylesheet" type="text/css" />

    <!-- Animation CSS -->
    <link href="@Url.Content("~/plugin/css/animate.css")" rel="stylesheet" type="text/css" />    

    <!-- Custom CSS -->
    <link href="@Url.Content("~/plugin/dist/css/sb-admin-2.css")" rel="stylesheet" type="text/css" />

    <!-- Custom Fonts -->
    <link href="@Url.Content("~/plugin/bower_components/font-awesome/css/font-awesome.min.css")" rel="stylesheet" type="text/css" />

    <link href="../../plugin/dateTimePicker/css/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css" />    
</head>
    <body>
        <div id="wrapper">
    <div>
        <label for="disabledSelect" style="color:#A94442; display:none;" id="lblTotalCollectibles"></label>
    </div>
        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0; background-color:#337AB7;">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    < span class="sr-only"> Toggle navigation < /span >
                    < span class="icon-bar">< /span >
                    < span class="icon-bar">< /span >
                    < span class="icon-bar">< /span >
                </button>
                <a class="navbar-brand" href="@Url.Content("~/BS/BSSSS")" style="color:White;">BS</a>
            </div>
            <!-- /.navbar-header -->

            <ul class="nav navbar-top-links navbar-right">
                <li style="margin-top:13px;">
                    <span class="fa fa-clock-o" style="color:White;" id="timeTxt"></span>
                </li>  
            </ul>
            <!-- /.navbar-top-links -->

            <div class="navbar-default sidebar" role="navigation">
                <div class="sidebar-nav navbar-collapse">
                    <ul class="nav" id="side-menu">                        
                        <li>

                        </li>  
                        <li> <!--style="display:none;"> -->

                        </li> 
                        <li> <!--style="display:none;"> -->

                        </li>
                        <li>
                            <a href="#"><i class="fa fa-wrench fa-fw" id="side-menu-filemaintenance"></i> File Maintenance <span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>

                                </li>
                                <li>

                                </li>
                            </ul>
                            <!-- /.nav-third-level -->
                        </li>                  
                    </ul>
                </div>
                <!-- /.sidebar-collapse -->
            </div>
            <!-- /.navbar-static-side -->
        </nav>
        <!-- Page Content -->
        <div id="page-wrapper" style="background-image:url(../../Images/bg.gif); background-attachment: fixed;">
            <div class="container-fluid">
                @RenderBody()
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="@Url.Content("~/plugin/bower_components/jquery/dist/jquery.min.js")" type="text/javascript"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="@Url.Content("~/plugin/bower_components/bootstrap/dist/js/bootstrap.min.js")" type="text/javascript"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="@Url.Content("~/plugin/bower_components/metisMenu/dist/metisMenu.min.js")" type="text/javascript"></script>

    <!-- DataTables JavaScript -->
    <script src="@Url.Content("~/plugin/bower_components/datatables/media/js/jquery.dataTables.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/plugin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/plugin/js/jquery.scrollUp.min.js")" type="text/javascript"></script>    

    <script src="../../plugin/dateTimePicker/js/moment-with-locales.js" type="text/javascript"></script>
    <script src="../../plugin/dateTimePicker/js/bootstrap-datetimepicker.js" type="text/javascript"></script>

    <!-- Custom Theme JavaScript -->
    <script src="@Url.Content("~/plugin/dist/js/sb-admin-2.js")" type="text/javascript"></script>


    <script src="@Url.Content("~/Scripts/userdefined/Sales/jsSales.js")" type="text/javascript"></script>
    </body>
</html>

最后为我的观点&gt; BS&gt; BSSSS.cshtml

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <div>
    <h1>aaaa</h1>
    </div>
</body>
</html>

以下是错误的picture

已更新

@Gaurav这是我按照你建议的方式发生的新错误。

NEW

1 个答案:

答案 0 :(得分:1)

方法1

将您的BSSSS.cshtml重命名为Index.cshtml并将其移至Views/Home文件夹(替换现有文件)。 将语句保留为return View();控制器的Home操作中的Index

方法2

BSSSS.cshtml文件保留在路径Views/BS/BSSSS.cshtml。在Home控制器的Index操作中,将return View();更改为return View("BSS/BSSSS.cshtml");