Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display version number on the footer of an MVC3 app

While we are in dev and doing daily builds, we would like to display the current version number on the footer of the pages in our MVC3 app. Makes it easier for the QA to log bugs.

I'm not sure how to do this. The footer is in the shared _layout.cshtml page.

I would like to use (Assembly.GetExecutingAssembly().GetName().Version.ToString()) to display it. I thought about using ViewData but still not sure how to format the HTML to get it to display.

like image 591
Rhonda Avatar asked May 25 '11 00:05

Rhonda


1 Answers

Since you just need it in dev, you could simply do

<footer>
    @System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
</footer>

This used to work back in the day (i think).

Now it indeed does not, so use this instead (from the answer linked in the comment):

@typeof(YourApplicationNamespace.MvcApplication).Assembly.GetName().Version
like image 68
Necros Avatar answered Nov 15 '22 10:11

Necros