Anand
Anand

Reputation: 1

Integrate ASP.NET Core MVC Application to existing ASP.NET MVC Application

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

Upvotes: 0

Views: 1057

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239290

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.

Upvotes: 1

Related Questions