2016-06-16 193 views
2

我想用源代碼學習一些東西,但是當我嘗試複製自己這段代碼時,我得到了該錯誤。加載資源失敗:服務器響應狀態爲403(禁止)MVC 5

我有一個視圖索引其中我試圖從另一個文件夾訪問一些.cshtml模板。

@{ 
    ViewBag.Title = "Index"; 
} 
<div ng-controller="inboxIndexCtrl"> 
    <div class="row"> 
     <div class="col-sm-1"> 
      <a ng-href="#/" id="InboxSubNav">Inbox</a> 
      <hr /> 
      <a ng-href="#/sent" id="InboxSubNav">Sent</a> 
      <hr /> 
      <a ng-href="#/create" id="InboxSubNav">Create</a> 
     </div> 
     <div class="col-sm-11"> 

      <div class="well" ng-view></div> 

     </div> 

    </div> 
</div> 

腳本:

var mail = angular.module('mail', ['ngRoute']); 

mail.config([ 
    '$routeProvider', ($routeProvider) => { 
     $routeProvider.when('/', { 
      templateUrl: 'Templates/Incoming.cshtml' 
     }) 
      // Registering path with controller relative to Inbox/Index 
      // This part is similar to RouteConfig.cs in ASP MVC 
      .when('/message/:id', { 
       // Templates are located inside Inbox. 
       templateUrl: 'Templates/Message.cshtml', 
       controller: 'oneMessageCtrl' 
      }).when('/create', { 
       templateUrl: 'Templates/Create.cshtml', 
       controller: 'createCtrl' 
      }).when('/reply/:id', { 
       templateUrl: 'Templates/Reply.cshtml', 
       controller: 'replyCtrl' 
      }).when('/sent', { 
       templateUrl: 'Templates/Sent.cshtml', 
       controller: 'sentCtrl' 
      }) 

      .otherwise({ redirectTo: '/' }); 

    } 
]); 

_layout已包括NG-應用<html ng-app="mail">。另外Angular bundle在Jquery之前加載,並且這是通過localhost完成的。

版本我使用:

Angular 1.3.0-beta4 
jquery-1.10.2 

頁面加載時,爲第二它加載<div class="well" ng-view></div>然後dissapear。

當我將鼠標懸停在鏈接上方時,路徑似乎很好。當我點擊鏈接時,它將繼續路徑,但由於403錯誤而不會加載任何內容。

這裏是一些鏈接:

http://localhost:49602/Messages/Index#/ 
http://localhost:49602/Messages/Index#/sent 
http://localhost:49602/Messages/Index#/create 

我的猜測是,我沒有使用角/ jQuery的的正確版本還是我失去了一些包?

試圖在瀏覽器中查看一個模板,並得到了另一個錯誤:與計算器的幫助

Server Error in '/' Application. This type of page is not served.

Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.

Requested URL: /Messages/Templates/Create.cshtml

+1

你可以試試 >> http:// localhost:49602/Messages /#/ >> http:// localhost:49602/Messages /#/ sent >> http:// localhost:49602/Messages /#/ create –

+0

well我得到這個:'HTTP Error 403.14 - Forbidden Web服務器被配置爲不列出這個目錄的內容。' – Eduard

+0

我還添加了這個 < /system.webServer>' – Eduard

回答

相關問題