Is it possible to host an asp.net MVC in the same folder as asp.net web forms app?

一笑奈何 提交于 2019-12-10 19:48:11

问题


I have a domain and a hosting account and I'd like to in a folder host an MVC app and in another host asp.net web forms app.

Is it possible?


回答1:


Yes, ASP.NET web forms and ASP.NET MVC applications can reside side-by-side in the same application. I have that in my current application and it works fine. You just have to make sure that your classic ASP.NET application paths don't conflict with your ASP.NET MVC routes -- seems that the MVC routing handler wins out. I've run into that a few times.

Here's a good article that walks through hosting web forms and MVC side-by-side.




回答2:


As others have said, this is most certainly possible. You'll likely want to modify your MVC routes to ignore requests for aspx or axd resources:

routes.IgnoreRoute("{resource}.aspx");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");



回答3:


Yes, it is possible. You can also have different web.config files for each folder. Of course, it depends on the hosting .NET version, if you can use MVC..




回答4:


You can also have your single hosting host multiple domains, or make a subdomain and host the legacy site there.




回答5:


This article shows in details how to do this: http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx



来源:https://stackoverflow.com/questions/9009669/is-it-possible-to-host-an-asp-net-mvc-in-the-same-folder-as-asp-net-web-forms-ap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!