Challenge authentication using a custom middleware.

Sometimes you write an ASP.NET Core application without using MVC. For example an microservice or an application serving static files.

Anyhow you might want to secure your application using authentication. I was facing the problem, how I could challenge authentication when I’m not using MVC.

The solution is writing a custom middleware that challenges authentication.

Share a LocalDB instance with other users on the computer

MS LocalDB has the possibility to share your personal LocalDB instance with other users on the computer.

You can use the CLI tool SqlLocalDb.exe to share the instance. It is available in the Developer Command Prompt of Visual Studio.

This is the documentation of the share action:

share|h ["owner SID or account"] "private name" "shared name"
    Shares the specified private instance using the specified shared name.
    If the user SID or account name is omitted, it defaults to current user.


C:\Windows\System32>sqllocaldb share contosolab\doering MSSQLLocalDB ShareLocalDb
Private LocalDB instance "MSSQLLocalDB" (owner: CONTOSOLAB\doering) shared with the shared name: "ShareLocalDb".

Important: the argument “owner SID or account” must be your own user not the user you want to share the instance with.

The instance then appears as .\ShareLocalDb in the list.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>sqllocaldb info

You can use the shared instance in connection strings like this:

Data Source=(LocalDb)\.\ShareLocalDb;database=MyDatabase;trusted_connection=yes;