0
我正試圖縮短新MVC 5項目中的About和Contact Urls。我嘗試過的所有東西都不起作用。縮短MVC中的關於Url 5
routes.MapRoute("ShortAbout", "About", New With {.controller = "Home", .action = "About"})
routes.MapRoute("ShortenUrl", "{action}", New With {.controller = "Home", .action = `"Index", .id = UrlParameter.Optional}, New With {.action = "About|Contact"})`
我錯過了什麼?我知道這一定很簡單。我想獲得像http://mysite/About
這樣的網址,而不是/ home/About。
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute("ShortAbout", "About", New With {.controller = "Home", .action = "About"})
routes.MapRoute("ShortenUrl", "{action}", New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional}, New With {.action = "About|Contact"})
End Sub
你能發佈RegisterRoutes()完整的代碼嗎? –