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

81,959

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

Share:
81,959
Eduard
Author by

Eduard

Updated on August 20, 2020

Comments

  • Eduard
    Eduard over 3 years

    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