Friday, May 1, 2009

Displaying last modified date of asp.net page.

Using System.IO Name space we can find out time when page was last modified. we can also display LastWriteTime,CreationTime etc. of asp.net page. here if the code to display LastAccssTime of asp.net page.

string filePath = Server.MapPath(Request.Path);
System.IO.FileInfo fInfo = new System.IO.FileInfo(filePath);
lblLastWriteTime.Text = fInfo.CreationTime.ToString();


Put this code in Page_Load event of your page.

Thanks.