2016-09-20 45 views
2

你好我開始學習網頁編程語言使用asp.net mvc4bootstrap。我在運行我的應用程序時遇到此錯誤(Server Error in '/' Application),但如果它在默認代碼中,它運行良好。'/'應用程序中的服務器錯誤。 Asp.net Mvc4

這是我的代碼

_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> 

,最後我查看> BS> 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

+0

看到這個職位:http://stackoverflow.com/questions/10971149/the-following-sections-have-been-defined-but-have-not-been-呈現爲layo –

+0

@GauravSinghJantwal wait2我開始閱讀它。 – KiRa

+0

@GauravSinghJantwal我們有同樣的錯誤,但建議的答案說'@RenderSection(「腳本」)',但我沒有那種類型的代碼。 – KiRa

回答

1

方法1

重命名BSSSS.cshtmlIndex.cshtml並將其移動到文件夾Views/Home(替換現有文件)。 請將return View();的說明留在Home控制器的Index操作中。

方法2

BSSSS.cshtml文件留在路徑Views/BS/BSSSS.cshtml。在您的Home控制器的Index行動改變return View();return View("BSS/BSSSS.cshtml");

+0

當時非常感謝。 – KiRa

相關問題