更新时间:2022-12-11 15:41:54
忽略了也启用了属性路由.
Noticed that attribute routing is also enabled.
routes.MapMvcAttributeRoutes();
您也可以直接在控制器中设置路线.
you can also set up the route directly in the controller.
[RoutePrefix("ComicBooks")]
public class ComicBooksController : Controller {
[HttpGet]
[Route("{PermaLinkName}")] //Matches GET ComicBooks/Spiderman
public ActionResult ShowComicBook(string PermaLinkName){
//...get comic book based on name
return View(); //eventually include model with view
}
}