c# - HttpWebRequest doesn't work except when fiddler is running -


this weirdest problem have run into. have piece of code submit post url. code doesn't work neither throws exceptions when fiddler isn't running, however, when fiddler running, code posts data successfuly. have access post page know if data has been posted or not. non-sense, it's situation running , confused.

byte[] postbytes = new asciiencoding().getbytes(postdata); httpwebrequest req = (httpwebrequest)webrequest.create("http://myurl); req.useragent = "mozilla/5.0 (windows; u; windows nt 6.1; en-us) applewebkit/534.10 (khtml, gecko) chrome/8.0.552.224 safari/534.10"; req.accept = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; req.headers.add("accept-charset", "iso-8859-1,utf-8;q=0.7,*;q=0.3"); req.headers.add("accept-language", "en-us,en;q=0.8"); req.method = "post"; req.contenttype = "application/x-www-form-urlencoded"; req.contentlength = postbytes.length; req.cookiecontainer = cc; stream s = req.getrequeststream(); s.write(postbytes, 0, postbytes.length); s.close(); 

if don't call getresponsestream() can't close response. if don't close response, end socket in bad state in .net. must close response prevent interference later request.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -