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 = "http://www.etantonio.it/it/index.aspx"

and you can see the trace results at
http://www.etantonio.it/it/trad_OK.aspx

while it is not working if I choose

sAddressTime =
"http://babelfish.altavista.com/babelfish/trurl_pagecontent?url=http%3a%2f%2fwww.etantonio.i t%2fIT%2fUniversita%2fMasterSatellitare%2findex.as px&lp=IT_EN";
and in this case you can see the trace results at
http://www.etantonio.it/it/trad_NOT_OK.aspx

the page I ask for could be regularly seen with a web browser at this
address :
http://babelfish.altavista.com/babel....aspx&lp=IT_EN
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
error:

************************************************** **************************
<%@ 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 =
""http://babelfish.altavista.com/babelfish/trurl_pagecontent?url=http%3a%2f%2fwww.etantonio.i t%2fIT%2fUniversita%2fMasterSatellitare%2findex.as px&lp=IT_EN";
// String sAddressTime = "http://www.etantonio.it/it/index.aspx";

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

many thanks for your help,

Antonio D'Ottavio
www.etantonio.it/en/

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
www.etantonio.it/en/

Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.