Using the Web Application version number from an assembly (ASP.NET/C#)

后端 未结 12 993
我寻月下人不归
我寻月下人不归 2020-12-07 18:39

How do I obtain the version number of the calling web application in a referenced assembly?

I\'ve tried using System.Reflection.Assembly.GetCallingAssembly().GetName

12条回答
  •  借酒劲吻你
    2020-12-07 19:04

    To add to the responders that have already posted. In order to get the assembly version in an ASP.Net web application you need to place a method in the code behind file similar to:

    protected string GetApplicationVersion() {
        return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
    }
    

    In the ASPX page you want to display the version number simply place:

    <%= GetApplicationVersion() %>
    

提交回复
热议问题