vmg vmg -4 years ago 189
C# Question

Display project version in ASP.NET MVC Core application (RC2)

How do I display application version from the project.json?
I am using

to autoincrement version, but I can't show the recent version. Here is what I'm trying:


This does not work, it displays "
" instead of real value from

I also tried this but it looks like it is no longer works in RC2:

@inject Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv
My version number is @(appEnv.ApplicationVersion)

Answer Source

As per this announcement, IApplicationEnvironment no longer exists.

You can still access the ApplicationVersion statically using:


It works for me. My project.json looks like this:

    "version": "",
    // all the rest

And in my index view, I have the following line at the top:


And I correctly get in the output. And when I change that value and restart (build) the application, the new version is shown there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download