Issue with routing in MVC .net framework - some controllers not routing correctly

Viewed 27

I've been working on a website, started off with the standard mvc template you get. I have several controllers, Home, Admin, User along with the bundled ones you get like Manage and Account. From googling I've changed my routing so instead of mysite.com/home/index I can just go straight to mysite.com

This is what I currently have

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "OnlyAction",
            "{action}",
            new { controller = "Home", action = "Index" }
        );

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

However, when using loginpartial template, the following action:

        @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })

On my dev environment, instead of taking me to https://localhost:44363/Manage/Index it instead shows https://localhost:44363/Manage and a corresponding 404. I also get the same issue on the user controller.

What do I need to change in my routing? Its still one of the areas I'm struggling understanding

Many thanks

0 Answers
Related