我需要我的網頁名稱中有短劃線。 E.G我們的願景剃刀文件名帶短劃線
我是MVC的新手& c#所以我可能會討論所有這些錯誤。
這裏是我的控制器:
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
//
// GET: /our-vision/
public ActionResult ourVision()
{
return View();
}
}
然後在我的意見,我有次/主頁/ ourVision.cshtml。
當我編譯並去http://localhost/ourVision
它的作品,但是當我去http://localhost/our-vision
它不。
這裏是我的路由:
routes.MapRoute(
"Default", // Route name
"{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
可能重複:http://stackoverflow.com/questions/30310/asp-net -mvc-how-do-i-enable-dashes-in-my-urls –
他使用mvc而不使用Razor。 – CharliePrynn
@CharliePrynn嗯,MVC是框架,Razor是可以與MVC一起使用的許多可能的視圖引擎之一。該解決方案仍然適用,因爲它是核心MVC的東西。 – Yuck