How to get the last updated date of each url in my website, using c#
I crawl my website and generate an xml sitemap. How do I get the date each page was last updated? T开发者_JAVA百科he examples I find of c# code to create a sitemap just use the current date, or the last updated time in the response header, which is always the current date.
Also, if I include the time in the lastmod tag, what is the correct time format? does it need to end with an offset to the UTC as in 2009-04-15T13:23:26+0000
Sample I was using in a vb.net website. LastWriteTime()
method
Last Updated:
'Added in auto last updated time for website
Dim writeTime As String
writeTime = String.Format(
My.Computer.FileSystem.GetFileInfo(
Me.Server.MapPath(Me.Page.Request.Path)).LastWriteTime,
"MM/DD/YYYY HH:MM:SS")
Response.Write(writeTime)
精彩评论