Is it possible to host an asp.net MVC in the same

2019-07-03 17:03发布

问题:

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