By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,149 Members | 958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,149 IT Pros & Developers. It's quick & easy.

Problem with HttpWebRequest to read a web page

P: n/a
Good Morning,
I need to read a web page, to do this I use the following code that
works well if I choose

sAddressTime = ""

and you can see the trace results at

while it is not working if I choose

sAddressTime =
" px&lp=IT_EN";
and in this case you can see the trace results at

the page I ask for could be regularly seen with a web browser at this
address :
but when I ask to open it with my script this is the error reported :
System.Net.WebException: The underlying connection was closed: The
server committed an HTTP protocol violation.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at ASP.Trad_NOT_OK_aspx.Page_Load(Object Src, EventArgs E) in
D:\Inetpub\webs\etantonioit\it\trad_NOT_OK.aspx:li ne 15
here it is the simple code and I hope you can help me to solve the

************************************************** **************************
<%@ Page Language="c#" Trace="true" Debug="true" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.IO" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E )
if (!Page.IsPostBack)
String sAddressTime =
"" px&lp=IT_EN";
// String sAddressTime = "";

HttpWebRequest req =
HttpWebResponse result = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
StreamReader reader = new StreamReader(ReceiveStream,
String respHTML = reader.ReadToEnd();
catch (Exception e)
Trace.Write("EX" , e.ToString());
<html><head><title>Etantonio</title></head><body ></body></html>
************************************************** **************************

many thanks for your help,

Antonio D'Ottavio

Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
The error raised from that server is this :

The underlying connection was closed: The server committed an HTTP
protocol violation.
Status: ServerProtocolViolation

how I can bypass it ?? Can you help me ??
Many thanks

Antonio D'Ottavio

Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.