Reputation: 3447
Angular Routing:
$locationProvider.hashPrefix("!").html5Mode(true);
$routeProvider
.when('/', { templateUrl: '/home/index', controller: 'homeCtrl' })
.when('/admin', { templateUrl: '/admin' })
.when('/cart', { templateUrl: '/shoppingcart/cart' })
.when('/login', { templateUrl: '/customer/login' })
.when('/logout', { templateUrl: '/customer/logout' })
...
.otherwise({ redirectTo: '/' });
MVC routing:
routes.MapRoute("HomePage",
"",
new { controller = "Home", action = "Spa" },
new[] { "Nop.Web.Controllers" });
routes.MapRoute(
"Default2",
"{.*}",
new { controller = "Home", action = "Spa" },
new[] { "Nop.Web.Controllers" });
routes.MapRoute("Logout",
"logout/",
new { controller = "Customer", action = "Logout" },
new[] { "Nop.Web.Controllers" });
CustomerController.cs: (mvc controller)
public ActionResult Logout()
{
return Redirect("/");
}
if i try http://domain.com/logout => the page loads forever and not return to homepage. Other pages load just fine.
Upvotes: 0
Views: 525
Reputation: 2316
Your logout requests are hitting your catch-all route before it can hit the logout
route definition. Try changing the order of your routes to the following:
routes.MapRoute("Logout",
"logout/",
new { controller = "Customer", action = "Logout" },
new[] { "Nop.Web.Controllers" });
routes.MapRoute("HomePage",
"",
new { controller = "Home", action = "Spa" },
new[] { "Nop.Web.Controllers" });
routes.MapRoute(
"Default2",
"{.*}",
new { controller = "Home", action = "Spa" },
new[] { "Nop.Web.Controllers" });
Also for debugging routes, Phil Haack's route debugger is excellent. You can find the Nuget package here: https://www.nuget.org/packages/routedebugger/
Upvotes: 1