Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I ran to an issue with routing using one layout with ASP.NET MVC and AngularJS. Here is an error:

http://localhost:2066/Administration/app/templates/admin.html Failed to load resource: the server responded with a status of 404 (Not Found)

Here is my AngularJs routing:

var app = angular.module("app", ['ngRoute', 'ui.bootstrap', 'blockUI', 'textAngular', 'LocalStorageModule']);

app.config(['$routeProvider', '$locationProvider', '$controllerProvider', '$provide', '$httpProvider',
    function ($routeProvider, $locationProvider, $controllerProvider, $provide, $httpProvider) {

        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        }).hashPrefix('!');

        var baseTemplateUrl = "app/templates/";

        $routeProvider
        .when('/', { // For Home Page
            templateUrl: baseTemplateUrl + 'index.html',
            controller: 'CategoryController'
        })
        .when('/Administration/Administration', {
            templateUrl: baseTemplateUrl + 'admin.html',
            controller: 'TabsetCtrl'
        })
        .otherwise({  
            controller: 'ErrorController'
        })

    }]);

With / everything is fine getting all the info, but if I want to redirect to Admin tab, getting routing error, somehow I need to get rid of that Administration in url, just use only /app/templates/.

Here is my Asp.Net mvc routing:

 public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }

and here is my part of the code in layout:

    <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
            <li>@Html.ActionLink("Home", "Index", "Home")</li>
            <li>@Html.ActionLink("Administration", "Administration", "Administration")</li>
        </ul>
        @Html.Partial("_LoginPartial")
    </div>

Any information would be very appreciated. Thanks in advance.

share|improve this question
    
Try not using the Razor @Html.ActionLink and just make a normal a link in html with the url you need. – mituw16 20 hours ago
    
Thanks for the answer, but still the same error. – DntQuitPls 19 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.