ASP.NET MVC - 在子目录中运行
我正在尝试在现有应用程序的子目录中部署 ASP.NET MVC 应用程序,但遇到了一些路由问题。我已经设置了文件夹结构,以便 MVC 应用程序的所有二进制文件和配置文件都正确位于根目录中,而其余内容位于子目录中。此外,我更新了 MVC 应用程序中的所有路由以反映子目录;然而,对应用程序的每个请求都会产生:
传入的请求不匹配 任何路线。
所有定义的路由都被忽略,包括默认路由:
routes.MapRouteLowercase(
"Main_Default",
"blog/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
我尝试启用 RouteDebug 来测试问题,但即使如此也没有被路由到。关于我还可以尝试什么有什么建议吗?
注意:这个问题不是一个重复。
I am attempting to deploy an ASP.NET MVC application in a subdirectory of an existing application and I am running into some routing issues. I have set up the folder structure such that all of the binaries and config files for the MVC app are correctly located in the root directory, while the rest of the content is in the subdirectory. Additionally, I updated all of the routes in the MVC application to reflect the subdirectory; however, every request to the application produces:
The incoming request does not match
any route.
All defined routes are being ignored, including the default route:
routes.MapRouteLowercase(
"Main_Default",
"blog/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
I tried enabling RouteDebug to test the issue, but even that is not getting routed to. Any advice on what else I can try?
Note: This question is not a duplicate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将其作为虚拟目录运行,而不仅仅是目录,否则您的路由将不会被调用。您不需要将虚拟目录的名称放入路由中。
这是我在 v-dir MVC 应用程序中设置的一条路线,效果很好......
Try running it as a virtual directory instead of just a directory, otherwise your routes are not going to be called. You will not need to put the name of the virtual directory in the route.
Here's a route that I have setup in a v-dir MVC app that works just fine...
看来我发现了问题。
除了二进制文件和配置文件之外,Global.asax 还必须放置在根目录中才能执行其代码。
谢谢你们。 :)
Looks like I found the problem.
In addition to the binaries and the config files, Global.asax must also be placed in the root in order for its code to be executed.
Thanks guys. :)