<分区>
Possible Duplicate:
How can I accomplish this type of URL in ASP.Net MVC2?
我想创建如下 HTML 链接:
/Auctions/Clothes
/Auctions/Electronics
/Auctions/Real Estate
这是我构建链接的方式:
<li>@Html.ActionLink("Ropa", "Index", "Anuncios", new { category = "Ropa" }, new { })</li>
<li>@Html.ActionLink("Libros", "Index", "Anuncios", new { category = "Libros" }, new { })</li>
问题是链接是这样使用的:
http://localhost:8589/Anuncios?category=Libros
我希望我的 URLS 看起来很漂亮,因此我希望上面的内容是这样的:
/Anuncios/Libros
关于如何解决这个问题有什么建议吗?这是 ActionResult 方法,澄清一下,这正是我想要它做的。它有效,除了 URL 很糟糕。
public ActionResult Index(string category)
{
AuctionRepository auctionRepo = new AuctionRepository();
var auctions = auctionRepo.FindAllAuctions().Where(a => a.Subcategory.Category.Name == category);
return View(auctions);
}