在网站内托管 MVC 应用程序
我有一个在 IIS 6.0 上运行的网站(不是 Web 应用程序 - 在 Visual Studio 中你有两个选项 - 创建网站/项目)。现在我想在MVC架构中开发一些功能。 因此,我在 Visual Studio 中创建了一个 MVC 应用程序,并且作为一个单独的应用程序在 localhost 上一切正常。现在我想在我已经部署的网站内托管这个 MVC 应用程序。
我在 IIS 6.0 的默认网站内创建了一个虚拟目录(MVCDir)。位于根文件夹中的 global.asax 文件我添加了路由功能 -
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.Ignore("{resource}.axd/{*pathInfo}")
routes.Ignore("{resource}.aspx/{*pathInfo}")
routes.MapPageRoute("Default4", "{controller}/{action}/{id}", "~/MVCDir", False, New RouteValueDictionary(New With {.controller = "Home", .action = "Index", .id = Mvc.UrlParameter.Optional}))
End Sub
*** 注意 - 如果我写的routes.ignoreRoute而不是路由,忽略它说 - IgnoreRoute不是System.Web.RoutingCollection的成员*
我称之为application_start函数内的路由函数 现在当我运行domain.com/home/index时
如何解决这个问题? 它说找不到资源
I have a website (not a web application- in visual studio you get two options-create a website/project) running on IIS 6.0. Now I want to develop few features in MVC architecture.
So I created one MVC application in visual studio and everything is working fine on localhost as a separate application. Now I want to host this MVC app also inside the website I have already deployed.
I created a virtual directory(MVCDir) inside the default website in IIS 6.0. The global.asax file which was in root folder I added the routing function-
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.Ignore("{resource}.axd/{*pathInfo}")
routes.Ignore("{resource}.aspx/{*pathInfo}")
routes.MapPageRoute("Default4", "{controller}/{action}/{id}", "~/MVCDir", False, New RouteValueDictionary(New With {.controller = "Home", .action = "Index", .id = Mvc.UrlParameter.Optional}))
End Sub
*** NOTE- If I write routes.ignoreRoute instead of routes,ignore it says- IgnoreRoute is not a member of System.Web.RoutingCollection*
I called this routing function inside application_start function
now when I run domain.com/home/index
How to solve this problem?
it says resource not found
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这是您的子应用程序从父应用程序继承配置的问题。当我尝试将应用程序放在网站下时,我遇到了类似的问题。
您需要将
封装在
标记中,并使用inheritInChildApplications="false"
示例:
这里您有更详细的解释。
Maybe this is a problem with you child application inheriting configuration from parent. I had a similar problem when trying to put an app under a website.
You'll need to wrap
<system.web>
in<location>
tag withinheritInChildApplications="false"
Example:
Here you have more detailed explanation.