简体   繁体   中英

Using MVC project with existing Web Forms project

I'm looking to roll some new functionality into an existing web forms website hosted in IIS, and was thinking of using MVC. I know you can do this in a fairly straight forward manner if you are just enabling MVC inside an existing web forms project. However, I would like to be able to separate the old code from the new by putting it in a new project. The old project is a bit of a mess and not organized well, so the further I can get from it the better.

However, I don't believe this is possible (or more correctly, is a bad idea in my case), for the following reasons:

  • The user is authenticated on the web forms site, so then I would have to put together some form of passing credentials to the new MVC site, and vice versa
  • I wouldn't be able to share global things like Session between the two
  • I would have to coordinate session times so that I didn't have the primary site time out if it hadn't been referenced in the set time
  • I would need a completely different root URL (though I could use the same domain) for the MVC based sites.

My main question is this - am I missing some obvious way to make them play nicely together as one cohesive unit, or am I right in assuming that if I spin it out to a separate web application project then they are essentially two different apps? If not, is there some other way I can bind the two together to appear, more or less, as one without actually combining the projects?

  • You could share user authentication if you a cookie to keep the user identifier. Then use the same library in both systems to decode the cookie, etc, etc.
  • Sharing session objects would be a much much more difficult thing to achieve.
  • Yes, that can happen.
  • You can set a different root URL for every system. (You can also set the default route on the MVC project to act as a proxy and fetch the webpage from the webforms webpage, but that is a bit more complicated to achieve).

In general, it sounds like you are going to spend a lot of time and a lot of headaches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM