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.i t/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.altav ista.com/babelfish/trurl_pageconte nt?url=http%3a% 2f%2fwww.etanto nio.it%2fIT%2fU niversita%2fMas terSatellitare% 2findex.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/babel....aspx&lp=IT_EN
but when I ask to open it with my script this is the error reported :
System.Net.WebE xception: The underlying connection was closed: The
server committed an HTTP protocol violation.
at System.Net.Http WebRequest.Chec kFinalStatus()
at System.Net.Http WebRequest.EndG etResponse(IAsy ncResult asyncResult)
at System.Net.Http WebRequest.GetR esponse()
at ASP.Trad_NOT_OK _aspx.Page_Load (Object Src, EventArgs E) in
D:\Inetpub\webs \etantonioit\it \trad_NOT_OK.as px: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="Syst em.Net" %>
<%@ import Namespace="Syst em.IO" %>
<script runat="server">
void Page_Load(Objec t Src, EventArgs E )
{
if (!Page.IsPostBa ck)
{
String sAddressTime =
""http://babelfish.altav ista.com/babelfish/trurl_pageconte nt?url=http%3a% 2f%2fwww.etanto nio.it%2fIT%2fU niversita%2fMas terSatellitare% 2findex.aspx&lp =IT_EN";
// String sAddressTime = "http://www.etantonio.i t/it/index.aspx";
Trace.Write("sA ddressTime",sAd dressTime);
try
{
HttpWebRequest req =
(HttpWebRequest )WebRequest.Cre ate(sAddressTim e);
HttpWebResponse result = (HttpWebRespons e)req.GetRespon se();
Stream ReceiveStream = result.GetRespo nseStream();
StreamReader reader = new StreamReader(Re ceiveStream,
Encoding.ASCII) ;
String respHTML = reader.ReadToEn d();
Trace.Write("re spHTML",respHTM L);
}
catch (Exception e)
{
Trace.Write("EX " , e.ToString());
}
}
}
</script>
<html><head><ti tle>Etantonio</title></head><body ></body></html>
*************** *************** *************** *************** *************** *
many thanks for your help,
Antonio D'Ottavio
www.etantonio.it/en/