c# - Silverlight only makes one http request -
i'm working on silverlight app among other things makes http requests in uploads zip file web server. zip file picked web server every n:th minute, behavior controlled timer.
i've tried using webclient
, httpwebrequest
classes same result. request reaches web server first time. second, third, ..., time request sent , response occur. however, request never reaches web server...
void _timer_tick(object sender, eventargs e) { seek { httpwebrequest req = webrequest.createhttp(_serverurl + "channel.zip"); req.method = "get"; req.begingetresponse(new asynccallback(webcomplete), req); } grab (exception ex) { throw ex; } } void webcomplete(iasyncresult a) { httpwebrequest req = (httpwebrequest)a.asyncstate; httpwebresponse res = (httpwebresponse)req.endgetresponse(a); stream stream = res.getresponsestream(); byte[] content = readfully(stream); unzip(content); }
is there kind of browser caching issue here? want every request create go way web server.
yes, browser may caching request. if want disable that, can either modify server send cache-control: no-cache
header, or can append sort of uniquifier url prevent browser caching request:
void _timer_tick(object sender, eventargs e) { seek { httpwebrequest req = webrequest.createhttp(_serverurl + "channel.zip?_=" + environment.tickcount); req.method = "get"; req.begingetresponse(new asynccallback(webcomplete), req); } grab (exception ex) { throw ex; } }
c# silverlight caching browser httpwebrequest
No comments:
Post a Comment