0

I discovered a defect on my website ... and I am not sure if it is a bug ... or it is by design.

I have the following route registered.

routes.MapRoute("EditProduct", // Route name
                "product/addproduct/{id}", // URL with parameters
                new { controller = "Product", action = "AddProduct", id = UrlParameter.Optional } 
                );

In _Layout.cshtml I have the following link defined:

  <li><a href="@Url.Action( "AddProduct", "Product")">Add new product</a></li>

If the current url contains the 'Id' parameter, for example: /product/details/5, the menu link from layout is generated /product/addproduct/5. It is taking the id parameter from RequestContext.

Is this a bug ... since in the helper I do not specify the parameters for my link? ... or this is by design?

Radu D
  • 3,505
  • 9
  • 42
  • 69

1 Answers1

0

I don't think you even need to specify a route here.

By default MVC3 uses the URL /Controller/Action/{id}.

Try removing your specified route and see if it works without.

Curtis
  • 101,612
  • 66
  • 270
  • 352