一、确认加载了MVC
二、添加Controllers/HomeController
Imports System.Web.Mvc
Public Class HomeController
Inherits System.Web.Mvc.Controller
Function Index() As ActionResult
Return Redirect("/swagger/ui/index")
End Function
End Class
三、添加 App_Start/RouteConfig.vb
Imports System.Web.Mvc
Imports System.Web.Routing
Public Module RouteConfig
Public Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute(
name:="Default",
url:="{controller}/{action}/{id}",
defaults:=New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional}
)
End Sub
End Module
四、调整 Global.asax
Imports System.Web.Http
Imports System.Web.Routing
Public Class WebApiApplication
Inherits System.Web.HttpApplication
Protected Sub Application_Start()
GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
RouteConfig.RegisterRoutes(RouteTable.Routes)
End Sub
End Class
以上即可。