5 Lessons Learned While Migrating from ASP.NET to ASP.NET Core

ASP.NET VS ASP.NET Core

Let me start by mentioning the best thing about the new ASP.NET Core. – The new ASP.NET Core is independent from Microsoft ecosystem.

This means, it is now possible to develop ASP.NET application on other platforms such as Linux and Mac.

Although, this is not it, there are many new improvements to the new ASP.NET Core framework which are listed as below.

  • ASP.NET Core provides support for more than 32,000 APIs.
  • The new .NET Standard 2.0 released along with ASP.NET Core is added new compatibility shim that allows any application developed using .NET Core to refer any full framework library.
  • ASP.NET Core offers better portability of codes to the new .NET Standard 2.0 library without requiring any major changes.
  • Lastly, when .NET Core version 1.0 was released, it didn’t have logging libraries as log4net wasn’t available. However, it has been added now using which you can now easily deploy applications on Mac or Linux.
Also Read:   Unleashing the Key Aspects of WordPress Website Typography

Now, after learning about all these improvements, I finally decided to move an existing ASP.NET application to ASP.NET Core.

Here are the lessons that I learned while doing so.

LESSON No. 1 – IIS is dead (kind of)

IIS isn’t really dead. You can still use it as a reverse proxy sitting in front of Kestrel to leverage the benefits of IIS that Kestrel does not have.

What is this Kestrel though? – Kestrel is basically an essential part of .NET Core framework that allows deploying any web app as easy as deploying a console app. In simple terms, all the self-hosted packages for web API, SignalR, and others are not needed anymore. Every web app developed using ASP.NET Core becomes self-hosted now.

LESSON No. 2 – HttpHandlers & HttpModules are Replaced By a New Middleware

The new middleware in ASP.NET Core has been designed to replace both handlers and modules. It is basically how Owin and other platforms handle this kind of functionality. In fact, Middleware is more easy to work with. And, you will not be able to configure them in a config file either. With new Middleware, both are set in code. You can learn more about it in ASP.NET docs.

LESSON No. 3 – The StreamReader Constructor Does No Longer Work With a File Path

Actually, many simple uses of standard libraries have been changed. For example, in ASP.NET the StreamReader was frequently used by passing in a file path, but in the new ASP.NET Core you will have to pass it in a stream. As a result, it may require small refactorings to use a FileStream, in addition to StreamReader everywhere.

Also Read:   typeahead.js autocomplete library inspired by Twitter search!

Another good example of change of use of standard libraries is the use of GetType(). The standard library now returns a better version of object (more simplified) for better performance reasons.

LESSON No. 4 – Web API is Now a Part of MVC

Both Microsoft and the community have decided to merge Web API and MVC with the release of new ASP.NET Core. The reason is because Both Web API and MVC follow same pattern for controllers and actions. Secondly, the Web API did not have a view engine like a Razor and was designed to be useful for REST APIs.

MVC, on the other hand, was created for standard web application development with HTML front-ends. As you can see, merging Web API and MVC made sense in many ways. So they merged them.

LESSON No. 5 – Basic Classes Have Been Moved Around to Different Packages

While I do not know the reason why, but some basic classes such as FileStream are no longer in the System.IO package. Instead, you’ll have to add the package System.IO.FileSystem.

These changes of basic classes may be confusing, mainly because we generally use class namespaces that don’t directly match the packages. But to clear the confusion, I have found a website that shows where some classes have been moved around.

Final Thoughts…

Microsoft has indeed made everything right with the release of ASP.NET Core. It is basically an interesting web framework to learn or build web application to shoot MVPs quickly in the market.

Overall, this has been an interesting experience for me as well as my team, which has helped us to Migrate as well as develop ASP.NET Core application from scratch.


Want to Support WittySparks? Why not use these links to buy stuff from Amazon US and Amazon IN. Maybe little purchase from these sites may help us to cut down our expenses. Thank You.

3 thoughts on “5 Lessons Learned While Migrating from ASP.NET to ASP.NET Core”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.