Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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/

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.