0

I have this route configuration

        routes.MapRoute(
            name: "catProducts",
            url: "Description/{action}/{id}",
            defaults: new { controller = "Home", action = "ProductDetail" }
        );



        routes.MapRoute(
            name: "Products2",
            url: "Category/{action}/{cat}/{subcat}",
            defaults: new { controller = "Home", action = "Products", subcat = UrlParameter.Optional }
        );

        routes.MapRoute(
            name: "Default",
            url: "",
            defaults: new { controller = "Account", action = "Login"}
        );

        routes.MapRoute(
            name: "Default1",
            url: "{controller}/{action}"

        );

When I am trying

http://localhost/B2BWebSite/Description/ProductDetail/3

it's somtime redirect right but sometime goes to login page

2 Answers2

0

There is no specific route defined for B2BWebSite. Hence when you go to http://localhost/B2BWebSite/Description/ProductDetail/3 it checks for default route and your Default route is Account/Login as below. Which is why it goes to login page.

 routes.MapRoute(
                name: "Default",
                url: "",
                defaults: new { controller = "Account", action = "Login"}
            );

Regarding, you question about sometimes it works and sometimes doesn't; probably has something to do with login information in the session. If user is logged in, it might not go to login page.

Polynomial Proton
  • 5,020
  • 20
  • 37
0

You may need to specify id in the first route.

routes.MapRoute(
        name: "catProducts",
        url: "Description/{action}/{id}",
        defaults: new { controller = "Home", action = "ProductDetail", id= UrlParameter.Optional  }
    );
samvietnam
  • 16
  • 2