Dejan's Web Log

Server-side, client-side, code snippets, scripts, automation, best practices, proven approaches, tips & tricks...

Loading RSA key pair from PEM files in .NET Core with C#

BouncyCastle wrapper for loading RSA keys from PEM files instead of XML files
Recently I wrote and article about using asymmetric keys for token based authentication in ASP.NET Core. As I was setting up the RSA keys to test the demo appliation I kept running to some challanges that did not make thigs going so smooth Challenge number 1 - OpenSSL ... read more

Token based authentication and Identity framework in ASP.NET Core - Part 3

Setting up asymmetric key token based authentication in ASP.NET Core application on top of Identity Framework
Recently I wrote about setting up .NET Core Identity Framework and Token based authentication in ASP.NET Core using symmetric key signing. The downside of this approach is that both identity and resource server share the same key for signing and validating the token ... read more

Token based authentication and Identity framework in ASP.NET Core - Part 2

Setting up token based authentication in ASP.NET Core application on top of Identity Framework
In article Token based authentication and Identity framework in ASP.NET Core - Part 1 I described how to setup identity library for storing user accounts. Now we are going to setup ASP.NET Core Web API project to issue the token for authenticated users so they can access protected resources. Identity Web API instance will be separated from from the resource Web API, so we'll have eventually two and possibly in future more resource services which will all use single identity server fr authentication and issuing access tokens. ... read more

Remote PowerShell Core session to a Linux host from Windows machine

Remote sessions using OpenSSH from Windows to Linux host
Starting from January 2018, Microsft has made PowerShell Core 6, a cross-platform tool available not only to Windows users which was the case so far with previous versions, but to Linux and Mac users as well. Since it was tool for Windows only, it had it's own ways for remoting using WinRM unlike Linux operating systems which primarily rely on SSH. Windows is great for editing and development, I find it really comfortable to work on with so many tools and platform available ... read more

Sending email in ASP.NET Core using SmtpClient and dependency injection

Using dependency injection to send email in ASP.NET Core
Starting with .NET Core 2.0, Microsoft introduced SmtpClient, identical implementation as in .NET 4. This made sending emails from the application a lot easier as there is functionality out of the box and you do not have to rely on the 3rd party nuget packages. If you inspect this class, you will see that the only interface it inherits is IDisposable, so it does not give you many options for injection unless you wrap it with your own implementation and interface, but since we are not going to go that deep into the dependency injection, we'll just focus on creating a client instance using .NET Core dependency injection framework. ... read more

Advanced versioning in ASP.NET Core Web API

Different approaches in ASP.NET Core Web API versioning
Some time ago I wrote an article about ASP.NET Core Web API versioning which describes route based Web API endpoint versioning. I love route versioning and to me it is the best way of versioning because it is pretty straight, but there are situations where this kind of versioning is not suitable. On you can find Microsoft.AspNetCore.Mvc.Versioning package which gives you more options on how you can version your Web API endpoints ... read more

Use different configuration based on environment value in ASP.NET Core

Different configuration per environment in ASP.NET Core
In .NET framework, having separate configuration is possible by having different web.config or app.config file transformations since in .NET framework configuration is stored in XML format. You can check more on this in article Separate configuration files per build config in Visual Studio IDE ... read more


read more

Umbraco CMS

read more


read more


read more