How are we supposed to set the IfModifiedSince header on HttpWebRequest? It seems that it has no setter:
using (var req = HttpWebRequest.Create(url) as HttpWebRequest)
{
req.KeepAlive = false;
req.HttpsAuthentCerts = certx509;
req.ReadWriteTimeout = 2000;
if (timestamp > DateTime.MinValue)
{
req.IfModifiedSince = timestamp; // <-- Compilation error here
}
The docs at HttpWebRequest.IfModifiedSince Property (System.Net) | Microsoft Learn show it working with a setter:
HttpWebRequest myHttpWebRequest= (HttpWebRequest)WebRequest.Create(myUri);
// Create a new 'DateTime' object.
DateTime targetDate = DateTime.Now;
// Set a target date of a week ago
targetDate.AddDays(-7.0);
myHttpWebRequest.IfModifiedSince = targetDate;
Bug or by-design?