Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print Version Number in ASP.NET MVC 4 app

Tags:

c#

asp.net-mvc

I have an ASP.NET MVC 4 application. Currently, I am setting the version of the application in the project properties under the "Application" tab. From here, I click the "Assembly Information..." button. Once there, I have entered "1 0 0 *" in the "Assembly version" field.

My question is, how do I show this value on my web page? Currently, I am trying the following

@System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() 

Unfortunately, it's always printing "0.0.0.0". Realistically, I'd like to have it print 1.0.0.xyz. I would also like to print the date/time when the last build occurred. However, I have no idea how to do that.

What am I doing wrong?

like image 303
JQuery Mobile Avatar asked Oct 02 '12 16:10

JQuery Mobile


People also ask

What is the latest ASP.NET MVC version?

ASP.NET Core MVC 3.1. 1 released on 14 January 2020 is the latest ASP.NET MVC version.

What version of MVC is in Visual Studio 2017?

ASP.NET MVC 6 is a platform, which is supported in cross platform. It will run Windows, Linux and Mac. The steps are given below to create simple ASP.NET MVC 6 in Visual Studio 2017.

What is ASP Net MVC5?

The ASP.NET MVC 5 Framework is the latest update to Microsoft's popular ASP.NET web platform. It provides an extensible, high-quality programming model that allows you to build dynamic, data-driven websites, focusing on a cleaner architecture and test-driven development.


1 Answers

To print the version number of the assembly in which was defined the controller that rendered this view:

@ViewContext.Controller.GetType().Assembly.GetName().Version 

and for the assembly date:

@File.GetCreationTime(ViewContext.Controller.GetType().Assembly.Location) 
like image 145
Darin Dimitrov Avatar answered Sep 20 '22 13:09

Darin Dimitrov