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.
@Html.ActionLink
and just make a normala
link in html with the url you need. – mituw16 20 hours ago