最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Failed to load resource: the server responded with a status of 403 (Forbidden) MVC 5 - Stack Overflow

programmeradmin1浏览0评论

I am trying to learn some things with a source code but when I try to replicate myself this code I am getting that error.

I have a View Index where I am trying to access some .cshtml Templates from another folder.

@{
    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>

Script:

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 have included ng-app<html ng-app="mail">. Also Angular bundle is loaded before Jquery, and this is done with localhost.

Versions I am using:

Angular 1.3.0-beta4
jquery-1.10.2

When the page loads, for a second it loads the <div class="well" ng-view></div> then dissapear.

When I hover the mouse above the links the path seems to be fine. When I click on links it goes on path but doesn't load anything due to 403 error.

Here some the links:

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

My guess is that I am not using the right versions of Angular/Jquery or am I missing some packages?

Tried to View in browser one Template and got another error:

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

I am trying to learn some things with a source code but when I try to replicate myself this code I am getting that error.

I have a View Index where I am trying to access some .cshtml Templates from another folder.

@{
    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>

Script:

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 have included ng-app<html ng-app="mail">. Also Angular bundle is loaded before Jquery, and this is done with localhost.

Versions I am using:

Angular 1.3.0-beta4
jquery-1.10.2

When the page loads, for a second it loads the <div class="well" ng-view></div> then dissapear.

When I hover the mouse above the links the path seems to be fine. When I click on links it goes on path but doesn't load anything due to 403 error.

Here some the links:

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

My guess is that I am not using the right versions of Angular/Jquery or am I missing some packages?

Tried to View in browser one Template and got another error:

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

Share Improve this question edited Jun 17, 2016 at 0:12 Eduard asked Jun 16, 2016 at 23:47 EduardEduard 7221 gold badge7 silver badges23 bronze badges 3
  • 2 can you try >> localhost:49602/Messages/# >> localhost:49602/Messages/#/sent >> localhost:49602/Messages/#/create – Farhan Commented Jun 16, 2016 at 23:50
  • well I get this: HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. – Eduard Commented Jun 17, 2016 at 0:02
  • 1 Also I have added this <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> – Eduard Commented Jun 17, 2016 at 0:06
Add a comment  | 

1 Answer 1

Reset to default 8

Well with the help from stackoverflow I solved the problem:

Here is the solution: Server Error in '/' Application. This type of page is not served

<add key="webpages:Enabled" value="true" />

It was set on false in my webconfig

发布评论

评论列表(0)

  1. 暂无评论