c# - Can't I set If-Modified-Since on a WebClient? -
c# - Can't I set If-Modified-Since on a WebClient? -
i using webclient
retrieve website. decided set if-modified-since
because if website hasn't changed, don't want again:
var c = new webclient(); c.headers[httprequestheader.ifmodifiedsince] = last_refreshed.touniversaltime().tostring("r");
where last_refreshed
variable in store time i've lastly seen website.
but when run this, webexception
text:
the 'if-modified-since' header must modified using appropriate property or method. parameter name: name
turns out api docs mention this:
in addition, other headers restricted when using webclient
object. these restricted headers include, not limited following:
the httpwebrequest
class has properties setting of above headers. if of import application set these headers, httpwebrequest
class should used instead of webrequest
class.
so mean there's no way set them webclient
? why not? what's wrong specifying if-modified-since
in normal http get
?
i know can utilize httpwebrequest
, don't want because it's much work (have bunch of casting, can't content string).
also, know cannot set http headers when using system.net.webrequest related, doesn't reply question.
c# httpwebrequest webclient if-modified-since
Comments
Post a Comment