c# - Getting "Stream not readable" when reading HttpWebResponse -


i'm trying "screen scrape" data have request follows (from fiddler)

post http://fallenlondon.storynexus.com/auth/emaillogin http/1.1 content-type: application/x-www-form-urlencoded referer: http://fallenlondon.storynexus.com/signup user-agent: mine accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 cache-control: max-age=0 l:  origin: http://fallenlondon.storynexus.com/ dnt: 1 accept-encoding: utf-8 accept-language: en-gb,en;q=0.8 cookie: asp.net_sessionid=05xq3gndu4nczvy5wsah5qyw; __utma=100212060.1740063036.1431282067.1431282067.1431284767.2; __utmb=100212060.14.10.1431284767; __utmc=100212060; __utmz=100212060.1431282067.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) host: fallenlondon.storynexus.com content-length: 54 

(the content credentials) - header matches request traced manually viewing web page in browser.

i send using httpwebrequest.getresponse() response back

http/1.1 200 ok access-control-allow-origin: * cache-control: no-cache, no-store, must-revalidate content-type: text/html; charset=utf-8 date: mon, 11 may 2015 20:54:15 gmt expires: -1 pragma: no-cache server: microsoft-iis/8.0 x-aspnet-version: 4.0.30319 x-aspnetmvc-version: 4.0 x-powered-by: asp.net x-server: web1 content-length: 16900 connection: keep-alive 

this (again) matches using browser. using fiddler, can see 17k of data (html), try read using...

var stream = response.getresponsestream(); if (stream == null) return null; using (var reader = new streamreader(stream, encoding.utf8)) {    var data = reader.readtoend();    reader.close();    return data; } 

i exception on "new streamreader" line stating "stream not readable" debugger shows me stream neither readable or writeable. 2nd page have read (the first 1 being simple request main url login page). works fine using same code. streams , requests have been closed after use.

google gives me no help, suggesting page error (no, status 200) or having read data (no, code goes straight here) not using threading @ that's not issue. have tried changing encoding (requesting gzip gives me smaller payload expected still can't read it) using c#.net 4.5.2 on win7 x64

does have idea i'm doing wrong?

d'oh! due "oversight" in code, trying read stream twice! working now


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Add class to another page attribute using URL id - Jquery -