Image representing the Articles category

Improving your ASP.NET Core site's file handling capabilities – part 1 – Introduction

Published 7 days ago

In a previous article I talked about hiding email capabilities behind an interface to make your code easier to unit test, to centralize configuration and to make it simple to switch to a completely different solution such as a cloud-based email handler like SendGrid, MailChimp or MailGun. Instead of newing up an SmtpClient directly, I created an interface called IMailSender and several concrete implementations that handle the sending of email differently (such as storing it on disk as .eml messages, sending it over SMTP or sending it with SendGrid).

In this article (and the next) I am going to talk about a similar improvement: handling files in a filesystem. I'll show you how to hide file handling - reading, writing and deleting files - behind an interface, similar to how I hid the emailing details behind IMailSender. I'll then create two concrete implementations: one using the local filesystem, the other using Azure storage. I'll then show you how to use dependency injection to inject one of the concrete classes at run-time to determine where your files are located and how to access them. With this setup, it's easy to write code to target yet another (remote) file storage solution like Box or OneDrive and plug that in without making any changes your application code.

Read on ...
Image representing the Articles category

Improving your ASP.NET Core site's e-mailing capabilities

Published 11 months ago

Many websites depend heavily on e-mail: they send account confirmation e-mails, password reset e-mails, order confirmations, back-in-stock notifications and much more. Despite its importance, I often see that sending e-mail is an overlooked area when writing well maintainable and stable code. It's also often overlooked when monitoring sites and lots of code I have seen just assumes the mail server is up and running. But problems will occur; mail servers will go down, passwords do expire or get changed without updating the web site and more.

In a preceding article you saw how to monitor your site's SMTP server using an ASP.NET Core health check. While it's great to be notified when your SMTP server is unavailable, it would be even better if your site has an alternative way to deliver the messages when the primary SMTP is not available.

In this article, I'll show you a couple of ways to improve the way you send e-mails from your ASP.NET Core applications. In particular, I'll discuss:

You'll find the full code for the article as a download at the end of this article, as well as in the Github repository for this article.

Read on ...
Image representing the Articles category

Using Standard Health Checks and Building your Own in ASP.NET Core

Published 11 months ago

Being able to monitor your ASP.NET Core web applications and APIs and detect any issues early on is crucial in ensuring your sites are up and running and in a healthy state. In previous articles I talked about creating a custom health check solution for ASP.NET Framework applications and implementing ASP.NET Core health checks with standard functionality. In this article I'll show you how to add and configure some existing, open-source health checks to monitor an SMTP server and the web server's disk space (these are just examples; there are many more health checks available that you can plug in to your own web site). And if the standard health checks aren't sufficient, you can build your own; something you'll see how to do in the second part of this article.

Read on ...
Image representing the Articles category

Improving IntelliSense for the asp-page Tag Helper using T4 Templates

Published 11 months ago

I find ASP.NET Tag Helpers super helpful. They provide powerful features and yet use clean markup. As an example, here's a tag helper that creates a link to an action method in some controller:

<a asp-controller="Contact" asp-action="Index">Get in Touch</a>

At run-time, ASP.NET then generates the correct URL for this action method and creates an href attribute on the anchor for it:

<a href="/contact">Get in Touch</a>

Read on ...
Image representing the Articles category

Implementing Health Checks in ASP.NET Core

Published 11 months ago

Being able to monitor your ASP.NET Core web applications and APIs and detect any issues early on is crucial in ensuring your sites are up and running and in a healthy state. In a previous article I talked about creating a custom health check solution for ASP.NET Framework applications. In this article I'll show you how to leverage the built-in Health Check framework along with some third-party open-source add-ons available for ASP.NET Core applications. You may want to check out the previous article to better understand health checks and why they are useful. And seeing the custom solution for the .NET Framework may have you appreciate the built-in ASP.NET Core functionality even more. And in this article I'll dive a little deeper into some existing third-party health checks that make monitoring your sites and services super easy and show you how to build your own health checks and plug them into the system.

Read on ...
  • «First
  • Previous
  • 1
  • Next
  • »Last

Mobile: False

Crawler: True

I: False