ASP.NET Core Tutorial

Most parts of elmah.io consist of small services. While they may not be microservices, they are in fact small and each do one thing. We recently started experimenting with ASP.NET Core (or just Core for short) for some internal services and we already released a number of blog posts about the subject. This post is meant to summarize on all of our material on ASP.NET Core.

What is ASP.NET Core

ASP.NET Core is an open source redesign of ASP.NET, able to run on multiple operating systems like Linux, Mac and Windows. Core lives alongside the existing ASP.NET and doesn't deprecate anything that you know (so far at least). Core runs on top of both .NET core as well as the full .NET framework. Since only .NET core runs on Mac and Linux, choosing to run Core on the full .NET framework, also binds you to run it on Windows (which may be a fine decision in many case).

Core contains a lot of the same features as available in ASP.NET (MVC, Web API etc.). With that said, you will find that developing applications in Core, is quite another experience. While Core definitely offer some nice features, ASP.NET still is the more mature platform. In time, Core may or may not replace ASP.NET entirely, but only time will tell.

Concepts in Core

Core offers a range of new concepts. While some are born out of OWIN and inspiration from Node.js, others are entirely new. Here are a list of terms to know about in Core:

Initialization

Web applications are no longer configured through Global.asax and web.config.. There's a new class in town, simply called Startup.cs to configure everything around Core.

Configuration

A new configuration system has been developed for Core. To read more, check out our blog posts about configuration:

Middleware

Much like OWIN and Node.js, Core uses the concept of middleware. Middleware are code components executed as part of the application pipeline. You will find middleware for a lot of different purposes like logging, exception handling, routing etc.

We wrote a blog post about middleware as well:

Logging

Core comes with a new logging framework called Microsoft.Extensions.Logging. If you want to know more about logging, read through our blog post:

Would your users appreciate fewer errors?

➡️ Reduce errors by 90% with elmah.io error logging and uptime monitoring ⬅️

Routing

Routing in its basic form, works much like in previous versions of ASP.NET. When looking into the details, you quickly spot some new features and fixes, that makes routing in Core really awesome. We blogged about routing here:

Error Handling

Error handling in Core is something that we are particular interested in :-) Stay tuned for future blog posts about the subject and make sure to check out our Error logging middleware in ASP.NET Core post.

Dependency Injection

Dependency injection always were a bit of a hack in ASP.NET. Since Core has been designed from the ground up, dependency injection is provided out of the box. The DI framework in Core doesn't necessarily replace your favourite IoC container, since it plays well with popular packages like Autofac and Windsor.

Health Checks

ASP.NET Core 2.2 introduces a new health check feature. Using health checks, you can use an uptime monitoring solution of your choice (or even a browser), to make sure that your website and its dependencies are always working. Read more in our tutorial here:

Kestrel

Kestrel is a new webserver bundled with Core. Kestrel is a lightweight web server, built on top of libuv (yes, the same as Node.js). Kestrel is used to serve requests in Core, but it isn't intended to be serving requests towards the public. For that purpose, integrations for other web servers and reverse proxies have been made available from Microsoft. A popular choice for now, is to wrap Kestrel behind IIS, but serving Core behind Apache or nginx, seems like obvious choices as well.

elmah.io: Error logging and Uptime Monitoring for your web apps

This blog post is brought to you by elmah.io. elmah.io is error logging, uptime monitoring, deployment tracking, and service heartbeats for your .NET and JavaScript applications. Stop relying on your users to notify you when something is wrong or dig through hundreds of megabytes of log files spread across servers. With elmah.io, we store all of your log messages, notify you through popular channels like email, Slack, and Microsoft Teams, and help you fix errors fast.

See how we can help you monitor your website for crashes Monitor your website