Show your version number in ASP.NET Core in 2 steps

I always find it useful when working on a project to be able to see the version number of the product somewhere. This doesn’t necessarily have to be shown to the end user later on, but when you’re deploying very often I find it very helpful.

Step 1: set your current version number

  • Right-click on your ASP.NET core web project, and select Properties
  • Go to the Package tab
  • Change the Package Version variable to the version you want
  • Save the properties, and Build the project

Step 2: Show the version number in your web application

Choose the place where you want to show your version number. You can use the following Razor code to show the version:

@Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion

Geef een reactie