问题
I have the below route setup but it is not coming out the way I am expecting. Yes I am still new to MVC.
The way it is coming out is like this.
http://localhost:29998/Home/States?make=Chrysler
the way I want it to come out is like this
http://localhost:29998/Home/Chrysler/States
Then of course once you click on your state it would look like this.
http://localhost:29998/Home/Chrysler/Florida
I would realy love to be able to remove "home from that altogether and just leave it as
http://localhost:29998/Chrysler/States
routes.MapRoute(
"States", // Route name
"{controller}/{action}/{make}", // URL with parameters
new { controller = "Home", action = "States", Make = "" } // Parameter defaults
);
回答1:
Here is your solution:
localhost:29998/Chrysler/States
routes.MapRoute(
"States", // Route name
"{make}/{states}/", // URL with parameters
new { controller = "Home", action = "GetStateData", make="", states="" }
);
You should place it below the default routing method so it does not take your controller values.
来源:https://stackoverflow.com/questions/10791778/asp-net-mvc-3-routing-multiple-parameters-without-query-string