Welcome to imar.spaanjaars.com
Unit Testing Authorization on your Controllers
Published 4 years ago
In many of my ASP.NET web applications (mostly MVC or Web APIs) I have a mix of content with endpoints that either require authentication and authorization or that can be accessed anonymously. For example I have mostly public content (such as my own web site) with a protected management (admin) section. Or I have a Web API project with many endpoints protected by authorization but with a few of them publicly available. To ensure you protect your controllers well, you have many different options. In this article I'll show you a short unit test that you can use to ensure your controllers are properly configured when using a mixed authorization scenario.
Read on ...Improving IntelliSense for the asp-page Tag Helper using T4 Templates
Published 4 years 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>
Implementing Health Checks in ASP.NET Core
Published 4 years 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 ...Implementing Health Checks in ASP.NET Framework Applications
Published 4 years ago
Being able to monitor your ASP.NET 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. With ASP.NET Core 2.2 and later this now comes in the box (as I'll show you in later articles) but for .NET Framework apps you'll have to use to kind of custom solution. To implement simple monitoring in ASP.NET Framework apps (i.e. non-Core applications), I usually add some custom code to my projects to provide health information from an endpoint and then use external tools to monitor that endpoint. In this article I'll show you how you can implement health checks using custom code targeting the .NET Framework (although it should also work on .NET Core). In future articles I'll then show you how you can set up similar checks in an ASP.NET Core app with standard functionality and how to extend the base system using existing third-party health checks like an SMTP server monitor, to make your health checks even more powerful.
Read on ...I'm back!
Published 4 years ago
I can't believe it's been almost 7 years since I last posted something here! Wow, time flies. Here's what happened.
Read on ...Prefixing ID columns with the table name in Entity Framework
Published 10 years ago
I recently got a question about the database configuration part of my article series on N-Layer design in ASP.NET. In my model, all classes inherit DomainEntity<T> that defines a primary key called Id. This in turn means all primary key columns in the database are called Id as well. The reader wanted to know if it was possible to prefix that column with the entity / table name. So, the Id column in the People table would be called PersonId, the Id in EmailAddress would be called EmailAddressId and so on. This has always been possible (and easy to do) for separate entities, but EF 6's custom conventions makes it a lot easier to do it for the entire model.
Read on ...ASP.NET N-Layered Applications - Extensions, Tools and Wrapping Up (Part 10)
Published 10 years ago
Note: this is part ten in a series of ten. If you rather read this entire series off-line, you can buy the full series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.
This is Part 10 in a series of 10 that show you how to build N-Layered applications using ASP.NET 4.5 and Entity Framework 5 Code First. In this part I’ll discuss a few miscellaneous topics that I haven’t touched in previous articles in the series.
Read on ...ASP.NET N-Layered Applications - Importing Data Using the API (Part 9)
Published 10 years ago
Note: this is part nine in a series of ten. If you rather read this entire series off-line, you can buy the full series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.
This is Part 9 in a series of 10 that show you how to build N-Layered applications using ASP.NET 4.5 and Entity Framework 5 Code First. In this part you’ll see how to build a command line application to import data from an external source (a CSV file in this case), using the application’s repository and model classes. Although this article is not related to ASP.NET directly, many ASP.NET developers may still benefit from it as importing data from an external resource is a common activity for ASP.NET developers.
Read on ...ASP.NET N-Layered Applications - Implementing a WCF 4.5 Frontend (Part 8)
Published 11 years ago
Note: this is part eight in a series of ten. If you rather read this entire series off-line, you can buy the full series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.
This is Part 8 in a series of 10 that show you how to build N-Layered applications using ASP.NET 4.5 and Entity Framework 5 Code First. In this part you’ll see how to build a WCF service that makes use of the model and repository projects I have shown in the first five articles in this series. The WCF service can be used by different types of applications to access contact people and their related data.
Read on ...ASP.NET N-Layered Applications - Implementing a Web Forms 4.5 Frontend (Part 7)
Published 11 years ago
Note: this is part seven in a series of ten. If you rather read this entire series off-line, you can buy the full series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.
This is Part 7 in a series of 10 that show you how to build N-Layered applications using ASP.NET 4.5 and Entity Framework 5 Code First. In this part you’ll see how to build a Web UI using ASP.NET Web Forms and make use of the model and repository projects I have shown in the first five articles in this series.
Read on ...Mobile: False
Crawler: True
I: False