在ASP.NET MVC 4应用程序中打印版本号 [英] Print Version Number in ASP.NET MVC 4 app
问题描述
我有一个ASP.NET MVC 4应用程序.目前,我正在应用程序"选项卡下的项目属性中设置应用程序的版本.在这里,单击组装信息..."按钮.在那里,我在程序集版本"字段中输入了"1 0 0 *".
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()
不幸的是,它总是打印"0.0.0.0".实际上,我希望将其打印为1.0.0.xyz.我还想打印最后一次构建的日期/时间.但是,我不知道该怎么做.
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.
我在做什么错了?
推荐答案
要打印定义了呈现此视图的控制器的程序集的版本号:
To print the version number of the assembly in which was defined the controller that rendered this view:
@ViewContext.Controller.GetType().Assembly.GetName().Version
以及集合日期:
@File.GetCreationTime(ViewContext.Controller.GetType().Assembly.Location)
这篇关于在ASP.NET MVC 4应用程序中打印版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!