Adding claims to existing identity

During moving one system from classic ASP.NET MVC to ASP.NET Core I faced an interesting challenge. Although access to system is based on Active Directory there is separate role management based on classic membership and roles providers. There are reasons why AD is not used for role management and I cannot change it. ASP.NET Core uses claims-based authentication and I needed to find a way to add role claims to authenticated identity. Here’s the solution.

Read more

Running ASP.NET Core 5 RC applications on Azure App Service

Although .NET 5 is officially in RC and not yet officially supported on Azure cloud we can still deploy ASP.NET Core web applications built for .NET 5 to Azure App Services. I made my first ASP.NET Core 5.0 deployment to Azure App Service last week. There has been no problems on Azure side and my application is running very stable. Here’s how I did it.

Read more

Using Structuremap in legacy ASP.NET MVC applications

Dependency Injection (DI) was also supported by classic ASP.NET MVC but there was no framework-level dependency injection like in ASP.NET Core. In this blog post I will show how to use Structuremap for dependency injection in ASP.NET MVC applications and how to resolve dependencies using built-in components in classes that doesn’t support dependency injection.

Read more

Building ASP.NET Core applications on Visual Studio Codespaces and Visual Studio Code

On the search for running development environments on cloud I stumbled upon service calles Visual Studio Codespaces. It’s nice service that moves development and debugging workloads to cloud and it makes it possible to use lightweight machines like tablets and hybrids for development. Here’s my overview of how to build ASP.NET Core web applications on codespaces and Visual Studio Code.

Read more

Using Dapper in ASP.NET Core applications

Times ago I blogged about micro ORM-s. I have been busy through all Covid-19 times learning technical side of DDD and during that I met again my old friend Dapper. There are applications where Dapper is used to query read-only data without overhead coming with ORM-s. Also there are simple applications where for one or another reason developers decided to keep as close to raw SQL as possible. This blog post is brief introduction to Dapper anbd how to use it in ASP.NET Core applications.

Read more

Creating subdomains to Azure DNS from ASP.NET Core

Multitenant wep applications detect current tenant usually by URL checking name of first level folder or subdomain. Usually tenants are defined by subdomain as it is easier to distribute them over data center, cloud services or hosting accounts. This blog post demonstrates how to build Azure DNS service client to create DNS records for multitenant application subdomains.

Read more

Inject users and roles dynamically to ASP.NET Core integration tests

After getting fake authenticated user to ASP.NET Core integration tests I made step further and introduced the way to use different user accounts. Using multiple users and roles instead of one test users is very common scenario in web applications. During my carreer I have seen only few business applications that doesn’t use different roles. This blog post demonstrates how to inject users dynamically to ASP.NET Core integration tests.

Read more

Create fake user for ASP.NET Core integration tests

After getting done with fake users for ASP.NET Core controller unit tests I wanted to make fake users available also in integration tests. It took some inventing and hacking but I made it work. This blog post shows you how to create fake users for ASP.NET Core integration tests and write effective extension methods to keep integration tests shorter.

Read more

Embedded Power BI reports with ASP.NET Core

Last year I had some projects where I had to embed Power BI reports to ASP.NET Core applications. There were easy cases that solved practically with copy-paste but I also had more complex situation where server-side code was needed because application uses custom authentication instead of Azure AD. This blog post covers both scenarios for embedding Power BI reportis to ASP.NET Core applications.

Read more

DataSet and DataTable based ad-hoc reporting with ASP.NET Core

In one of my projects I have some ASP.NET Core views that display multiple tables with reporting data. Data comes from SQL Server views and stored procedures and these can be modified in database without deploying application to server again. I came out with very common solution in ASP.NET Core to solve this problem using raw SQL commands and shared views for DataTable and DataSet. Here’s what I did.

Read more

Using configurable composite command in multi-tenant ASP.NET Core application

My previous posts about tenant-based dependency injection and using composite command in ASP.NET Core culminated with idea to use configurable composite commands in multi-tenant ASP.NET Core applications. Configurable composite commands make it easy to tweak save and update processes that contain multiple steps of what some can be custom and their activation is based on tenant configuration. Here’s how to build thost composite commands.

Read more