I have set up an ASP.NET MVC project, and everything is working great, but I do have one problem with the routing. My Global.asax looks like this:
public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );
    }
So, nothing out of the ordinary. My problem is that when I link to a controller/action/params with an HTML.ActionLink like so:
<%= Html.ActionLink("My link", "SomeAction", "SomeController", new {param="someParam"})%>
it should generate (at least what makes sense in my head) a link such as: http://www.localhost/SomeController/SomeAction/someParam.
But instead it generates a link like this: http://localhost/SomeController/SomeAction?param=someParam
If i manually make a link that links to the expected result (SomeController/SomeAction/someParam) then the right controller and action are called, but the parameter defined in the action method is always null.
Any ideas?
try adding:
routes.MapRoute(
                    "Default",                                                                                              // Route name
                    "{controller}/{action}/{param}",                                                   // URL with parameters
                    new { controller = "Home", action = "Index", param = "" }  // Parameter defaults
            );
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With