我想在url中的單詞之間添加' - '或'+'。例如網址,如:如何在asp.net中編寫url?mvc
http://localhost/bollywood/details/23-abhishek-back-from-dubai-holiday.htm
我的路由模式爲
routes.MapRoute(
name: "AddExtension",
url: "{controller}/{action}/{id}-{title}.htm",
defaults: new { controller = "Bollywood", action = "Details" }
);
我創造我的觀像這樣的鏈接:
@Html.ActionLink(item.n_headline, "Details", new { id = item.News_ID, title = item.n_headline.ToSeoUrl() }, htmlAttributes: null)
我的寶萊塢控制器是這裏
public ActionResult Details(int? id, string controller, string action, string title)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
tblBollywood tblbolly = db.tblBollywood.Find(id);
if (tblbollywood == null)
{
return HttpNotFound();
}
return View(tblbollywood);
}
當前網址的外觀如何? item.heading的內容是什麼?它是如何生成的? –