help in using HttpWebResponse c# -


i need in finding better way in downloading url using httpwebresponse

i used next code

    httpwebresponse myboot = httpwebrequest.create("http://www.wwenews.us/m1.php?id=441229").getresponse() httpwebresponse;     streamreader myboot_content = new streamreader(myboot.getresponsestream(), encoding.getencoding("windows-1256"));     string temp_data = myboot_content.readtoend(); 

but problem says

the server committed protocol violation. section=responseheader detail=cr must followed lf 

appears me when trying parsing http://www.wwenews.us/m1.php?id=441229

please me download string of site

note: test solution code before present had tested several solutions , no 1 solve problem

add reference system.configuration project , add following method.

public static bool setunsafeheaderparsing()     {         assembly oassembly = assembly.getassembly(typeof(system.net.configuration.settingssection));         if (oassembly != null)         {             type oassemblytype = oassembly.gettype("system.net.configuration.settingssectioninternal");             if (oassemblytype != null)             {                  object oinstance = oassemblytype.invokemember("section",                   bindingflags.static | bindingflags.getproperty | bindingflags.nonpublic, null, null, new object[] { });                  if (oinstance != null)                 {                     fieldinfo objfeild = oassemblytype.getfield("useunsafeheaderparsing", bindingflags.nonpublic | bindingflags.instance);                     if (objfeild != null)                     {                         objfeild.setvalue(oinstance, true);                         return true;                     }                 }             }         }         return false;     } 

call method setunsafeheaderparsing() before use httpwebrequest.create method call.

its problem server. server not following http specifications. .net client default adhere specs , flags potential problem.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -