0

I am using asp.net mvc2 and would like my site to show details (of 123) if a user enters foo.com/123. What is the route value I should specify for this, and in what order? I tried

routes.MapRoute(
    name: "foobar",
    url: "{id}",
    defaults: new { controller = "foo", action = "bar", id = UrlParameter.Optional }
);

but I get a 404.

Any help is appreciated.

krolik
  • 5,712
  • 1
  • 26
  • 30
Ra.
  • 289
  • 1
  • 3
  • 16

1 Answers1

1

routes.MapRoute( name: "foobar", url: "{id}", defaults: new { controller = "foo", action = "bar", id = UrlParameter.Optional } );

should be as follows

        routes.MapRoute(
                "Default",              // Route name
                "{controller}/{action}/{id}",  // URL with parameters
                new { controller = "foo", action = "bar", id = ""// Parameter defaults

            );
Ashes
  • 324
  • 1
  • 6
  • 21