0

Action method looks like

public virtual ActionResult Show(int productId, bool isValid, bool getByStoreId = false)

When I call this action I get url like

.../Product/Show/221?isValid=True&getByStoreId=True

But I want to display just

.../Product/Show/221

Does T4MVC has some shortcut for this?

routes.MapRoute(
                "ProductsShow_Default",
                "Product/{action}/{articleId}",
                MVC.Product.Show()
            );
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
1110
  • 7,829
  • 55
  • 176
  • 334

1 Answers1

1

By default, any parameters that you put in the RouteValueDictionary for a link that are not contained in any route will by default be added to the query string. Your only way around not putting them in the query string is mapping a route for them, but they're still going to be displayed in the URL.

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
  • So if I understand correct if I need action that requires 4 parameters but I want to display only 2 in url the best solution is to find a way to use that action with 2 parameters instead 4 because all parameters from action method must be part of url? – 1110 Apr 20 '12 at 21:52
  • Yes correct, *although* if you're finding yourself sending more and more parameters to a controller, you should think about your design. Ask yourself, is there any other way I can get this data *without* having to send it all to an action? If it's a post request, you should really be sending a model back to the action with all the fields that you need contained within the model :) – Mathew Thompson Apr 20 '12 at 21:55