How to programmatically retrieve the deployment time of an ASP.NET web site

May 26, 2016, (updated on August 4, 2017), Software Development

In one of my web projects, I wanted to append the web site deployment time to the JavaScript URLs. This way the browser uses the cached file version until a new web site version is deployed.

To do so, I looked for a way to read the deployment time of the currently running ASP.NET web site. It’s actually very simple, just read the modified date of the applications Web.config:

var configPath = Server.MapPath("~/Web.config");
var deploymentTime = File.GetLastWriteTime(configPath);

Do you known a better way to do this?

Tweet about this on TwitterShare on FacebookEmail this to someoneShare on TumblrShare on LinkedIn

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax