Reputation: 1191
Can someone please explain to me why this route :
routes.MapRoute(
"ListingDetails",
"{city}-{propertyType}-for-sale-MLS-{mlsId}",
new {controller= "Search", action="Details"}
);
Does not match this action:
public async Task<IActionResult> Details(int mlsId, string city, string propertyType, string mls)
{
var listing = _listingService.GetListingByMlsId(mlsId);
return View(listing);
}
I've listed the route as the first one, so there is no route before it that is capturing it. Instead of it matching I'm just getting Search/Details?mlsId=...&propertyType=...
Upvotes: 0
Views: 42
Reputation: 6710
The mls
argument is the culprit. You should be able to fix it by assigning a default value to the mls
argument:
public async Task<IActionResult> Details(... string mls = "something")
Or defining a default value in the route:
new {controller= "Search", action="Details", mls="something"}
Upvotes: 1