ASP.NET MVC Routing two parameters with static string in between -


this routing:

routes.maproute(null,     "shelves/{id1}/products/{action}/{id2}",     new { controller = "products", action = "list", id1 = "", id2 = ""}); 

the thought can this:

http://server/shelves/23/products/edit/14 

and able edit product 14 on shelf 23. checking route debugger, path matches routing, when try navigate route debugger off, shows me http 404 error. know why happening?

well, starters, id1="" line going problematic, because can't make optional that's not @ end.

i tried on system, , works fine.

this route:

routes.maproute(     "shelf-route",     "shelves/{id1}/products/{action}/{id2}",     new { controller = "products", action = "list", id2 = "" } ); 

this controller:

public class productscontroller : controller {     public string list(string id1, string id2)     {         return string.format("id1 = {0}, id2 = {1}", id1, id2);     } } 

i tried urls like:

http://localhost:14314/shelves/23/products/list/14
http://localhost:14314/shelves/23/products

and worked fine.

when tried url "edit" in it, did remember make edit action? if there's no edit action, you'll 404.


Comments

Popular posts from this blog

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -