简体   繁体   中英

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? The 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM