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:
Web applications are no longer configured through
web.config.. There's a new class in town, simply called
Startup.cs to configure everything around Core.
A new configuration system has been developed for Core. To read more, check out our blog posts about configuration:
- AppSettings in ASP.NET Core
- Config transformations in ASP.NET Core
- Configuration with Azure App Services and ASP.NET Core
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:
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 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 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 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.
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 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.
We monitor your websites
We monitor your websites for crashes and availability. This helps you get an overview of the quality of your applications and to spot trends in your releases.
We notify you
We notify you when errors starts happening using Slack, Microsoft Teams, mail or other forms of communication to help you react to errors before your users do.
We help you fix bugs
We help you fix bugs quickly by combining error diagnostic information with innovative quick fixes and answers from Stack Overflow and social media.