3

I have one default route in my routeconfig.cs file

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

It will hide Home/Index as Url in browser. My target is to display localhost:44300/Login instead of localhost:44300/Home/Index (but internally it will call Home/Index) and I want to hide Home/Details action method as url

1
  • defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional } Commented Feb 4, 2016 at 6:40

1 Answer 1

2

You can change your default route to Account controller and to your necessary Action method:

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

Update:

It is not possible as MVC has a convention that RouteTable should be look like that: controller/action or vice versa.

If you exclude controller from the route, you'll get an exception:

The matched route does not include a 'controller' route value, which is required.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.