我试图让它成为可能,所以如果有人试图转到/内容,他们被发送到一个特定的控制器(在这种情况下内容,然后在网址后面的以下细节作为参数传递。
网址为http://localhost:51118/content/1/7/test.html
我试过了:
routes.MapRoute("content", "content", new { controller = "Content", action = "Index", id = UrlParameter.Optional });
我试图整合一个cms,这就是为什么url就是它
编辑:
public class ContentController : Controller
{
public ActionResult Index()
{
var model = new Content();
return View(model);
}
}
答案 0 :(得分:2)
您的路线不正确。只有在您访问http://localhost:51118/content
网址时,您才会被路由到内容控制器。如果您想指定更多的paramateres,您应该在路线中添加更多部分。
routes.MapRoute("content", "content/{id1}/{id2}/{content}", new { controller = "Content", action = "Index"});
public class ContentController : Controller
{
public ActionResult Index(int id1, int id2, string content)
{
var model = new Content();
return View(model);
}
}