ASP.Net version / build number

I have ASP.Net (.net 3.5 / C #) and I want to show the version number / build number and date. What is the best way to control this and is it possible to automate the inclusion of numbers in an assembly?

What is the standard for version numbers and build numbers?

I am using VS 2008, how would I get the data and assign a string value so that I can show in the footer of the webpage?

+21
Jul 22 '09 at 21:12
source share
2 answers

If you are using a web application project, you can do it like this:

Assembly web = Assembly.Load("App_Code"); AssemblyName webName = web.GetName(); string myVersion = webName.Version.ToString(); 

If you use a website project - almost the same ...

 Assembly web = Assembly.GetExecutingAssembly(); AssemblyName webName = web.GetName(); string myVersion = webName.Version.ToString(); 
+29
Jul 22 '09 at 21:37
source share

You can set the first two parts of the version number and leave a wildcard for the compiler to autofill the last two parts by editing GlobalAssemblyInfo.cs like this:

 [assembly:AssemblyFileVersion("1.0.*")] 

It automatically fills in the last two parts with the number of days since January 1, 2000 and the number of seconds since midnight. This may help in the second part of your query to display the date / time when the version was built.

+21
Jul 22 '09 at 21:22
source share



All Articles