我有一个在本地调试和测试时完美运行的 web 应用程序。但是,当我将站点发布到生产服务器时,路由就搞砸了。这是因为它在生产服务器上作为子项目运行。
测试:http://localhost:xxx/ 生产:http://remotehost/webapp/
我应该如何设置路由?
这是我当前的路由设置(大部分是默认设置)。当我访问http://remotehost/webapp/时,服务器会显示默认的 Controller 操作。但是当我对控制器进行硬编码时(http://remotehost/webapp/Project/它不起作用......
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute("ProjectsByCategory", "Project/Category/{id}", _
New With {.controller = "Project", .action = "ListByCategory", .id = ""}, _
New With {.id = "^[0-9]+"})
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = "Project", .action = "Index", .id = ""} _
)
End Sub