1
可以说,我已经两个Web地址ASP.NET MVC可选页参数
http://www.example.com/page/one
http://www.example.com/page/one/subOne
我如何让他们由同一个控制器来处理。目前正在处理顶端地址,但第二个正在由不显示页面的回发函数处理。
所以对于我的路由配置,我有
routes.MapRoute("PageRule", "page/{id}", new { Controller = "document", action = "Index", id = UrlParameter.Optional });
routes.MapRoute("Page2Rule","page/{id}/{misc}", new { Controller = "document", action = "Index", id = UrlParameter.Optional });
,并在控制器我有
// GET: Document
public ActionResult Index(string id, string misc)
和
// Post
[HttpPost]
public ActionResult postcomment(string gCaptcha,string txtName, string txtEmail, string txtMessage)
请尝试阅读本文:http://stackoverflow.com/questions/5061249/asp-mvc-使用两个可选参数进行路由 – David