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:

accept connection content-length expect (when value set "100-continue") if-modified-since range transfer-encoding

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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -