I'm not sure how to convert this AttributeRoute into an MVC5 route.
[GET("", IsAbsoluteUrl = true)] // => main home page.
[GET("Index")]
public ActionResult Index(..) { .. }
The IsAbsoluteUrl
is one of the things that is confusing me.
I'm not sure how to convert this AttributeRoute into an MVC5 route.
[GET("", IsAbsoluteUrl = true)] // => main home page.
[GET("Index")]
public ActionResult Index(..) { .. }
The IsAbsoluteUrl
is one of the things that is confusing me.
根据此处找到的注释:http: //attributerouting.net/#route-prefixes该IsAbsoluteUrl
标志旨在忽略RoutePrefix
控制器上定义的。例如:
[RoutePrefix("MyApp")]
public class MyController : Controller {
[GET("", IsAbsoluteUrl = true)] //1
[GET("Index")] //2
public ActionResult Index() {
...
}
}
因此,使用“标准”AttributeRouting(因为没有更好的名称),以下路由应该映射到您的 Index() 方法:
MVC5 中新的基于属性的路由具有类似的功能(基于前者),只是语法略有不同(参见http://blogs.msdn.com/b/webdev/archive/2013/10/17/attribute-routing-在-asp-net-mvc-5.aspx )
[RoutePrefix("MyApp")]
public class MyController : Controller {
[Route("~/")] //1
[Route("Index")] //2
public ActionResult Index() {
...
}
}
波浪号~
似乎等同于IsAbsoluteUrl
.