I tryed to write a program that sends web request and receives response in C# consol.
When i execute it, it was always giving the exception as title on webRequest.GetResponse().
Finally i found what was the problem by googling.
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
The solution is just to add app.config file and add following BOLDED lines in it.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HTTPTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<HTTPTest.Properties.Settings>
<setting name="Setting" serializeAs="String">
<value>value</value>
</setting>
</HTTPTest.Properties.Settings>
</applicationSettings>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
The solution is just to add app.config file and add following BOLDED lines in it.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HTTPTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<HTTPTest.Properties.Settings>
<setting name="Setting" serializeAs="String">
<value>value</value>
</setting>
</HTTPTest.Properties.Settings>
</applicationSettings>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
If you're using it in Web app just put this in web.config file.