title: Getting assembly version of executing web application
body: <p>I want to implement some cache busting code in my library which can be integrated with ASP.NET web applications/sites. This will be implemented through appending a version string to the end of URLs. The default version provider I'd like to provide for cache busting would use the assembly version of the host web site.</p>
  
  <p>Currently, this is essentially how I'm extracting this version number:</p>
  
  <pre><code>HttpContext.Current
             .ApplicationInstance
             .GetType()
             .Assembly
             .GetName()
             .Version
             .ToString()
  </code></pre>
  
  <p>Unfortunately, at least for my sample test site, <code>Assembly</code> for the application instance is a generated assembly (I guess because the <code>global.asax</code> is compiled into a new assembly). In <a href="https://stackoverflow.com/questions/7463284/get-web-application-assembly-name-regardless-of-current-executing-assembly">Get web application assembly name, regardless of current executing assembly</a>, SLaks says you can use <code>BaseType</code> to get the actual site assembly's type, but I assume that if a site doesn't use a <code>global.asax</code> file, <code>BaseType</code> would give you something in the BCL.</p>
  
  <p>Is there any reliable way to extract the assembly version number for an ASP.NET web application? I'm also up for alternative approaches for generating a unique-per-build token that wouldn't require extra build steps for the application developer.</p>