My issue is that I customer Map Route in MVC which takes three parameters. When I supply all three or just two, the parameters are passed from the URL to my controller. However, when I only supply the first parameter, it is not passed and returns null. Not sure what causes this behavior.
Route:
routes.MapRoute(
name: "Details", // Route name
url: "{controller}/{action}/{param1}/{param2}/{param3}", // URL with parameters
defaults: new { controller = "Details", action = "Index", param1 = UrlParameter.Optional, param2 = UrlParameter.Optional, param3 = UrlParameter.Optional } // Parameter defaults
);
Controller:
public ActionResult Map(string param1, string param2, string param3)
{
StoreMap makeMap = new StoreMap();
var storemap = makeMap.makeStoreMap(param1, param2, param3);
var model = storemap;
return View(model);
}
string param1 returns null when I navigate to:
/StoreMap/Map/PARAM1NAME
but it doesn't return null when I navigate to:
/StoreMap/Map/PARAM1NAME/PARAM2NAME