Know your version of Web Application

Once the web application is published to production, after a while it becomes difficult to know exactly which version is in production. One of the way to find it without any ambiguity is to flash the version number on the footer tag next to copyright text.

Code in aspx page

<div id="AssemblyVersionInfo">
  <%=AssemblyVersionInfo%>
<div>

Code in Codebehind page

 public string AssemblyVersionInfo { get; set; }

 protected void Page_Load(object sender, EventArgs e)
 {
      SetAssemblyVersionInfo();
 }

 private void SetAssemblyVersionInfo()
 {
    Assembly assembly =
Assembly.LoadFrom(
Server.MapPath("bin\\<ApplicationDllName>.dll"));
Version ver = assembly.GetName().Version;
AssemblyVersionInfo = "Version : "
   + ver.Major.ToString()
   + "." + ver.Minor.ToString()
   + "." + ver.Build.ToString()
   + "." + ver.Revision.ToString();
 }
Advertisement

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: