I have a function that send the request by the HttpWebRequest and get the HttpWebResponse from that request but I have the server committed a protocal violation. Section=ResponseStatusLine failed at the
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Can someone shows me the right direction of what I did wrong? thanks.
Here is an error:
The server committed a protocol violation. Section=ResponseStatusLine
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine
Source Error:
Line 276: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); Line 277: // execute the request Line 278: HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Line 279: // we will read data via the response stream Line 280: Stream resStream = response.GetResponseStream();
Here is the function that Check Request Status and failed at
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Attention to all web developers who are using Skype! Make sure to uncheck the option for using port 80 and 443 from Tools\Options\Connection dialog.
In that article, it says that if you are using Skype which I'm not, I'm using the VS 2005 to develope an HTTP Handler class and always get the
The server committed a protocol violation. Section=ResponseStatusLine.
I ran some search and found some article saying
you can add the following <httpWebRequest useUnsafeHeaderParsing="true" /> in the Web Config file to solve the server committed a protocol violation. Section=ResponseStatusLine, but
it conflict with the <system.web> to <system.net> and gets the following errors, so how do I fix this issue? thanks...
Attention to all web developers who are using Skype! Make sure to uncheck the option for using port 80 and 443 from Tools\Options\Connection dialog.
In that article, it says that if you are using Skype which I'm not, I'm using the VS 2005 to develope an HTTP Handler class and always get the
The server committed a protocol violation. Section=ResponseStatusLine.
I ran some search and found some article saying
you can add the following <httpWebRequest useUnsafeHeaderParsing="true" /> in the Web Config file to solve the server committed a protocol violation. Section=ResponseStatusLine, but
it conflict with the <system.web> to <system.net> and gets the following errors, so how do I fix this issue? thanks...
Based on my understanding, When you add the 'system.net' element to the web.config, you get the error message above. If I have misunderstood you, please feel free to let me know.
The error message indicates that the 'system.net' element can't be contained in the 'system.web' section.
To better understand your issue, could you please confirm the following information:
Please make sure that the 'system.net' element isn't contained in the 'system.web' section.
If you still get the error message, could you please post the complete web.config here?
The correct web.config should like as follow:
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
I hope this helps.
Thomas Sun
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
That problem <System.net> has been solved, but still have "The server committed a protocol violation. Section=ResponseStatusLine" at the
response = (HttpWebResponse)request.GetResponse();
even though I add the <httpWebRequest useUnsafeHeaderParsing="true" /> inside the <System.net>,
I tested several times with the url request string in the HTTPHandler class, sometimes this error by pass and sometimes it gives me this error again ""The server committed a protocol violation. Section=ResponseStatusLine" How do I resolved
this error? thanks
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine
Source Error:
Line 287: request = (HttpWebRequest)WebRequest.Create(url);
Line 288: // execute the request
Line 289: response = (HttpWebResponse)request.GetResponse();
Line 290: // we will read data via the response stream
Line 291: Stream resStream = response.GetResponseStream();
I have the same issue. I have changed the web.config as suggested but still get "The server committed a protocol violation. Section=ResponseStatusLine". I get the error when I POST three time in session. The first POST is good, the second or third fails
with the protocol error. Only one of the two will fail, it is not consistent. If I pause between POST (break point) all three function.
Among the other more complicated configurations that can cause this problem is a simple solution - if you've are using FTP server over SSL ("FTP secure") You may get the error message "The server committed a protocol violation" as well.
In that case, simply set
myftpRequest.EnableSsl= true;
(where myftpRequest is of type FtpWebRequest/)
FtpWebRequest C# The server committed a protocol violation
boston_ma
Member
162 Points
604 Posts
The server committed a protocol violation. Section=ResponseStatusLine
Sep 07, 2007 01:09 PM|LINK
Hello,
I have a function that send the request by the HttpWebRequest and get the HttpWebResponse from that request but I have the server committed a protocal violation. Section=ResponseStatusLine failed at the HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Can someone shows me the right direction of what I did wrong? thanks.
Here is an error:
The server committed a protocol violation. Section=ResponseStatusLine
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine
Source Error:
Here is the function that Check Request Status and failed at HttpWebResponse response = (HttpWebResponse)request.GetResponse();
private string CheckRequestStatus(string statusFileName, string sLog){
bool bRptReady = false;//HttpWebRequest request;
// HttpWebResponse response;
StringBuilder sb = new StringBuilder();string url = null;
int startPos;int endPos;
int len;long loopCtrl1 = 0;
string strFileName;TraceLog(sLog, "I am in CheckRequestStatus");
url = "http://www.abc.com/" + statusFileName;// used on each read operation
byte[] buf = new byte[256];while (bRptReady == false){
if (loopCtrl1 == 500){
loopCtrl1 = 0;
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();// we will read data via the response stream
Stream resStream = response.GetResponseStream();string strTemp = null;
int count = 0;do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0){
strTemp = Encoding.ASCII.GetString(buf, 0, count);sb.Append(strTemp);
}
} while (count > 0);startPos = sb.ToString().IndexOf("Report Complete");
if (startPos > 0)bRptReady = true;request.Abort();
response.Close();
//resStream.Close();
}
loopCtrl1++;
}
startPos = sb.ToString().IndexOf("Report Complete") + 26;endPos = sb.ToString().IndexOf("zip;");len = endPos - startPos + 3;
strFileName = sb.ToString().Substring(startPos, len);
return strFileName;}
boston_ma
Member
162 Points
604 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Sep 07, 2007 08:36 PM|LINK
anyone knows this problem, thanks
Haissam
All-Star
37421 Points
5632 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Sep 07, 2007 09:03 PM|LINK
I didnt get this error before, but i googled a little and return with the below link
http://www.codeattest.com/blogs/martin/2006/06/server-committed-protocol-violation.html
Hope this helps,
HC
MCAD.NET
| Blog |
boston_ma
Member
162 Points
604 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Sep 10, 2007 01:24 AM|LINK
Thanks Haissam for replying...
In that article, it says that if you are using Skype which I'm not, I'm using the VS 2005 to develope an HTTP Handler class and always get the The server committed a protocol violation. Section=ResponseStatusLine. I ran some search and found some article saying you can add the following <httpWebRequest useUnsafeHeaderParsing="true" /> in the Web Config file to solve the server committed a protocol violation. Section=ResponseStatusLine, but it conflict with the <system.web> to <system.net> and gets the following errors, so how do I fix this issue? thanks...
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
Warning 1 The element 'system.web' has invalid child element 'system.net'. List of possible elements expected: 'anonymousIdentification, authentication, authorization, browserCaps, clientTarget, compilation, customErrors, deployment, deviceFilters, globalization, healthMonitoring, hostingEnvironment, httpCookies, httpHandlers, httpModules, httpRuntime, identity, machineKey, membership, mobileControls, pages, processModel, profile, roleManager, securityPolicy, sessionPageState, sessionState, siteMap, trace, trust, urlMappings, webControls, webParts, webServices, xhtmlConformance, caching'.
Error 2 Unrecognized configuration section system.web/system.net.
Thomas Sun –...
All-Star
64969 Points
5621 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Sep 11, 2007 03:38 AM|LINK
Hi,
Based on my understanding, When you add the 'system.net' element to the web.config, you get the error message above. If I have misunderstood you, please feel free to let me know.
The error message indicates that the 'system.net' element can't be contained in the 'system.web' section.
To better understand your issue, could you please confirm the following information:
The correct web.config should like as follow:
<configuration> <appSettings/> <connectionStrings/> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="true"/> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Windows"/> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> </system.web> <system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true" /> </settings> </system.net> </configuration>I hope this helps.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
boston_ma
Member
162 Points
604 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Sep 11, 2007 01:05 PM|LINK
Thanks Thomas for replying...
That problem <System.net> has been solved, but still have "The server committed a protocol violation. Section=ResponseStatusLine" at the response = (HttpWebResponse)request.GetResponse(); even though I add the <httpWebRequest useUnsafeHeaderParsing="true" /> inside the <System.net>, I tested several times with the url request string in the HTTPHandler class, sometimes this error by pass and sometimes it gives me this error again ""The server committed a protocol violation. Section=ResponseStatusLine" How do I resolved this error? thanks
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine
Source Error:
Avarice
Member
93 Points
104 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Jun 19, 2008 08:44 PM|LINK
I am experiencing the same error. Can anyone solve this protocol violation error?
fatihcewik
Member
2 Points
10 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Dec 11, 2009 12:29 PM|LINK
Does anyone know the solution?
The underlying connection was closed: The connection was closed unexpectedly
I have same problem:((
Fatih
The underlying connection was closed: The connection was closed unexpectedly
www.fatihcevik.com
jmsides
Member
18 Points
6 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Dec 24, 2009 05:18 PM|LINK
I have the same issue. I have changed the web.config as suggested but still get "The server committed a protocol violation. Section=ResponseStatusLine". I get the error when I POST three time in session. The first POST is good, the second or third fails with the protocol error. Only one of the two will fail, it is not consistent. If I pause between POST (break point) all three function.
HELP?
Thanks.
"protocol violation" webrequest post
DBConner
Member
8 Points
5 Posts
Re: HttpWebRequest and HttpWebResponse gets the server committed a protocol violation
Apr 01, 2010 09:36 PM|LINK
Among the other more complicated configurations that can cause this problem is a simple solution - if you've are using FTP server over SSL ("FTP secure") You may get the error message "The server committed a protocol violation" as well.
In that case, simply set
myftpRequest.EnableSsl= true;
(where myftpRequest is of type FtpWebRequest/)
FtpWebRequest C# The server committed a protocol violation