How to display an ASP.net MVC project version in page?
In WinForms, I'd use Application.ProductVersion
.
I've tried using System.Reflection.Assembly
开发者_Python百科in various ways but can never get the version of just the MVC project.
Provided this code is explicitly in the MVC project (rather than in a helper assembly), you should be able to use System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(3)
, which returns the major, minor, and revision numbers. Otherwise you might want to use something like typeof(HomeController).Assembly.GetName().Version.ToString(3)
.
精彩评论