1

我想设置以下形式的路由(如在 HTTP 处理程序中)

控制器/ * / * / * /*(任意深度)

我是 MVC 路线的新手,但我想设置一个基本上类似于的路线

MyController/{UrlSegments}

因此,例如 MyController/assets/images/logo.png 将转到 MyController 并将“assets/images/logo.png”作为参数传递给路由

4

1 回答 1

4

If you set up your route mapping like this:

routes.MapRoute(
    name: "Default",
    url: "{controller}/{*stuff}",
    defaults: new { controller = "Default", action = "DefaultAction" }
);

Then when you hit

/Default/one/two/three/four

It will hit the DefaultAction on the DefaultController and you will need a string parameter called stuff that will have a value of

one/two/three/four
于 2013-06-20T16:16:47.127 回答