Display Application version on page footer using C# and VB.Net in ASP.Net

Last Reply 5 days ago By dharmendr

Posted 5 days ago

hello,

i have asp dot net project and connect wtih team foundation server.

my boss asked me to do version on footer on application and with each change version number should auto increment so we know on which version we are pls advice how to do that

Posted 5 days ago

Hi nauna,

Add a Label to your master page footer where you would like to display the version.

Import the namespace System.Reflection

In Page_Load event of master page write the below code.

C#

protected void Page_Load(object sender, EventArgs e)
{
    Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
    lblVersion.Text = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
}

VB.Net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Dim version As Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
    lblVersion.Text = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision)
End Sub

The version set from the Applications Assembly information is displayed in the form.

For auto increment the version refer below links.

https://support.microsoft.com/en-in/help/556041

https://stackoverflow.com/questions/10229711/assemblyinfo-version-information-asterisks

https://www.zachburlingame.com/2011/02/versioning-a-net-assembly-with-visual-studio/

https://www.technical-recipes.com/2018/how-to-automatically-increment-build-versions-in-visual-studio/