Problem with HttpWebRequest to read a web page

E

etantonio

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/babe...versita/MasterSatellitare/index.aspx&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/babe...versita/MasterSatellitare/index.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(IAsyncResult 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:line 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/babe...versita/MasterSatellitare/index.aspx&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/
 
E

etantonio

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top