如何在页面中显示ASP.net MVC项目版本?

mat*_*wen 4 asp.net-mvc

在WinForms中,我会使用Application.ProductVersion.

我尝试过System.Reflection.Assembly以各种方式使用,但永远无法获得MVC项目的版本.

Age*_*191 7

如果此代码显式在MVC项目中(而不是在帮助程序集中),您应该能够使用System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(3),它返回主要,次要和修订号.否则你可能想要使用类似的东西typeof(HomeController).Assembly.GetName().Version.ToString(3).

  • 我用过`typeof(HomeController).Assembly.GetName().Version.ToString(3)`它的工作原理 (7认同)