I am using the C# HttpClient to simulate a request to download a CSV file from a server. I need to check the LastModified dateof the file against the LastModified date of the previous file I downloaded to check if the file has changed.
HttpClient gets a HttpResponseMessage when I make the request, but every time I check
response.Headers.Date.Value
I get the current Date/Time that the request was made. I understand that if the page I'm requesting the file from is generated by a DB or by some other dynamic method, the LastModified value will be the time that the request was made.
However, I have tried the same process using the older HttpWebRequest/Response and I found that
response.Headers[HttpResponseHeader.LastModified]
Will return the date that the file was last changed, e.g. the 2 different methods return different dates, HttpWebResponse gives a date of 1/12/2017, and HttpResponseMessage gives a date of 3/30/2017.
How can I get the file change date using HttpWebResponse?