对于一个项目,我必须(不幸地)匹配一些确切的 url。
所以我认为这不会是一个问题,我可以使用“MapRoute”,将 url 与所需的控制器匹配。但我不能让它工作。
我必须映射这个 URL:
http://{Host}/opc/public-documents/index.html
至
Area: opc
Controller: Documents
Action: Index
另一个例子是映射
http://{Host}/opc/public-documents/{year}/index.html
至
Area: opc
Controller: Documents
Action:DisplayByYear
Year(Parameter): {year}
我在我的区域()尝试了这个,但没有成功ocpAreaRegistration.cs
:
context.MapRoute("DocumentsIndex", "opc/public-documents/index.html",
new {area="opc", controller = "Documents", action = "Index"});
context.MapRoute("DocumentsDisplayByYear", "opc/public-documents/{year}/index.html",
new {area="opc", controller = "Documents", action = "Action:DisplayByYear"});
但是我遇到了一些 404 错误 :( 当我尝试访问它时。我做错了什么?