0

I am having an existing ASP.NET MVC application running in production. Now my customer came up with a new requirement/enhancement, and he wants to develop it with ASP.NET Core MVC. New enhancement will be a new standalone module. And after development completion, he wants to integrate it with existing ASP.NET MVC application.

I wanted to know that, is it possible to integrate these two applications, because ASP.NET Core is completely different framework rewritten from scratch, and old application uses .NET Framework 4.6.x.

Any help or any kind of link that guides me on this will be very much appreciated.

Thanks in advance.

Anand Neema

2
  • Create your new functionality using .Net Standard 2.0, you should be able to reuse that for framework 4.6.2. See learn.microsoft.com/en-us/dotnet/standard/net-standard Commented May 6, 2019 at 5:25
  • Thanks Johan. One more thing, will I be able to share the sessions and connection string as well with this approach. Currently my connection string is in web.config in ASP.NET MVC, and once I have the new functionality ready, I want that connection to be available for the new application as well. Commented May 6, 2019 at 6:35

1 Answer 1

1

Your question is actually quite broad, because "integration" is a broad topic. It covers many different aspects of the application and the exactly methodology depends on the an intimate knowledge of those applications.

That said, generally speaking, ASP.NET MVC and ASP.NET Core are completely separate platforms. You cannot "integrate" them in the sense of how you use to be able to simultaneously run Web Forms and MVC code in the same ASP.NET MVC project. They will be two separate applications that will need to be deployed independently.

You can "share" the connection string, which is to say you can share the database, but you will need to make a number of decisions in that regard. For example, if the current MVC project uses EF6, you will need to also use EF6 in the Core project in order to share the same entity classes. That means, for the moment, targeting .NET Framework, rather than .NET Core. However, .NET Core 3.0 promises to run EF6 natively. Alternatively, you can use EF Core and treat the database as existing, scaffolding in the entities. This will result in some code duplication, but may be an acceptable compromise, depending on the circumstances.

Things like sessions, cookies, and auth can be shared, but it may require fundamental changes to the ASP.NET MVC project. Namely, ASP.NET Core uses data protection providers for encryption and decryption, rather than the machine key approach of ASP.NET. However, via its support of OWIN, ASP.NET MVC5 can also support data protection providers for encryption/decryption. As such, if you switch over to using data protection there, and share the key ring between the two apps, then each will be able to decrypt things encrypted by the other. However, if you aren't already using data protection in your MVC app, then the change could be somewhat painful.

If you only care about sharing auth, that can be achieved alternatively via a centralized auth provider such as Identity Server. That would allow the two apps to operate independently of each other but still share a common user/role store and support SSO. However, that too, may require some substantial changes to the existing MVC app. It's all trade-offs.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks Chris for the detailed description. Let me give you a brief overview what I want to achieve. I am working on a prototype in which, I am having a MVC 5 web application configured inside IIS. Now, I want to add a new ASP.NET Core application inside this MVC 5 application. I configured the ASP.NET Core application inside the MVC 5 application, but it is not working. So trying to figure out is it possible to add a ASP.NET Core application inside a MVC 5 application.
Are you talking about deploying it as a virtual application under the site in IIS?
If so, you can, but you need to be very careful. You'll need to explicitly turn off web.config inheritance on every section of your main app's web.config, and remember to do so if you add new sections in the future. Aside from that, you'll still need a separate app pool and the Core app must be deployed independently.
Thanks Chris. Core App I am deploying independently. How can I turn off web.config inheritance?
I tried to turn off web.config inheritance using <location path="." inheritInChildApplications="false"> <system.web> ...system.web stuff </system.web> </location>, and enabled directory listing in IIS. When I am navigating to core app from borwser I am getting directory structure. I am not able to see the web page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.