0
我不知道如何將此AttributeRoute轉換爲MVC5路由。如何將此修復程序轉換爲ASP.NET MVC5路由?
[GET("", IsAbsoluteUrl = true)] // => main home page.
[GET("Index")]
public ActionResult Index(..) { .. }
IsAbsoluteUrl
是讓我困惑的事情之一。
我不知道如何將此AttributeRoute轉換爲MVC5路由。如何將此修復程序轉換爲ASP.NET MVC5路由?
[GET("", IsAbsoluteUrl = true)] // => main home page.
[GET("Index")]
public ActionResult Index(..) { .. }
IsAbsoluteUrl
是讓我困惑的事情之一。
基於此處找到的註釋:http://attributerouting.net/#route-prefixesIsAbsoluteUrl
標誌旨在忽略Controller上定義的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-in-asp-net-mvc-5.aspx)
[RoutePrefix("MyApp")]
public class MyController : Controller {
[Route("~/")] //1
[Route("Index")] //2
public ActionResult Index() {
...
}
}
的波浪~
似乎是等同的IsAbsoluteUrl
。