Skip to content

Printing Web Application Version Number in ASP.NET MVC

This is a quick and easy way I found to print the current version number as outlined in your AssemblyInfo.cs file for printing in an ASP.NET MVC view:

[sourcecode language='html']
<%= typeof(MyController).Assembly.GetName().Version.ToString() %>

Replacing MyController of course with your appropriate MVC controller name. This technique may not just apply to ASP.NET MVC, I suppose if you fed the typeof() statement a class name to your main executing class even in a Web App or Windows App this would work.

Don't do the mistake I did and reference typeof(MyController).GetType().Assembly... as this will return 'mscorlib' :)

VN:F [1.9.1_1087]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Bookmark and Share
kick it on DotNetKicks.com
Shout it

NOW, FOR A WORD FROM OUR SPONSORS

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*
My name is Graham O'Neale and I'm a software architect from Gold Coast, Australia. I am an overtime thinker, full time coder and awake part time in the real world. I have a keen interest in software development, particularly in the realm of programming (C#, ASP.NET, ASP.NET MVC, LINQ (2 SQL), Entity Framework, Silverlight, Blend, WCF, WPF) and a keen interest in the cutting edge and innovation. I have a new found love for design patterns, ALT.NET practices and well crafted software architecture. The purpose of this blog is to express any thoughts, findings, tips and gripes along my travels in the wonderful world of coding and technology...