Mike Gmez Mike Gmez - 26 days ago 10
AngularJS Question

Angular MVC routing prefix

Application was working fine yesterday, but after modifying a few things here and there, all hell broke loose. My api/xxx calls and root template calls are all being prefixed with the home controller:



Config files seem to be fine, dont really know where the issue is. Any idea guys? (thanks.)

.when('/home', { templateUrl: '/home/main', controller: 'MainController' })
.when('/accounts', { templateUrl: '/home/accounts', controller:'accountsController'})
.when('/reports', { templateUrl: '/home/reports', controller:'reportsController'})
.when('/login', { templateUrl: '/home/login', controller: 'loginController' })
.when('/SignIn', { templateUrl: '/home/SignIn', controller: 'loginController' })
.when('/logout', { templateUrl: '/home/logout', controller: 'loginController' })
.otherwise({ redirectTo: '/home' });
.controller('RootController', ['$window', '$rootScope', '$scope', '$route', '$routeParams', '$location',
function ($window, $rootScope, $scope, $route, $routeParams, $location) {
$scope.$on('$routeChangeSuccess', function (e, current, previous) {
$scope.activeViewPath = $location.path();

public static void RegisterRoutes(RouteCollection routes)


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

Answer Source

The issue seemed to be mostly related to my posting from my form's login page. For some reason, it kept the controller "Home" as part of the path from there on. I just replaced the form action, from calling a method in the mvc, to calling a web api method from angular. It works fine now.