Create one ActionResult:
public class AuctionController : Controller { public ActionResult AuctionCategoryDetails(string categoryName) { var model = repository.GetAuctionsForCategory(categoryName); return View(model); } }
Then create one route:
routes.MapRoute( "AuctionCategoryDetails", "Auctions/{categoryName}", new { controller = "Auction", action = "AuctionCategoryDetails" });
So, when you show a list of categories (rather than individual details);
<% foreach (var category in Model.Categories) { %> <%: Html.RouteLink("Category Details", "AuctionCategoryDetails", new { categoryName = category.CategoryName }); <% } %>
This will result in a list of such links:
<a href="/Auctions/Clothes">Category Details</a> <a href="/Auctions/RealEstate">Category Details</a>
Is that what you are after?
source share