all groups > asp.net security > september 2005 >
You're in the

asp.net security

group:

ReadXml (DataSet) and WebException (401)


ReadXml (DataSet) and WebException (401) Marcos Martínez
9/26/2005 12:00:00 AM
asp.net security: I am trying to generate and to consume a file RSS dinamicamente. I generate
it correctly, if I call from the explorer (http://localhost/Prueba/rss.aspx)
or an application client RSS Bandit, for example, everything works
costraight.
But if I want to load "http://localhost/Prueba/rss.aspx" in a pagina
(http://localhost/Prueba/Lector.aspx) in metodo Page_Load:
XmlTextReader reader = null;
try
{
//Get the XML data
reader = new XmlTextReader(http://localhost/Prueba/rss.aspx);

// return a new DataSet
DataSet ds = new DataSet();
ds.ReadXml(reader);
}
catch
{
throw;
}
finally
{
if(reader!=null)
reader.Close();
}
It gives a WebException - "Error in the remote server: (401) nonauthorized
"and I do not understand because.
That it happens? Because can be read from other applications and no in the
same Web site?
A greeting and thanks.
Marcos
***************************************************************************
Estoy intentando generar y consumir dinamicamente un archivo RSS.Lo genero
correctamente, si lo llamo desde el explorador
(http://localhost/Prueba/rss.aspx) o una aplicación cliente RSS Bandit, por
ejemplo, todo funciona corectamente.
Pero si quiero cargar "http://localhost/Prueba/rss.aspx" en una pagina
(http://localhost/Prueba/Lector.aspx) en el metodo Page_Load:
XmlTextReader reader = null;
try
{
//Get the XML data
reader = new XmlTextReader(http://localhost/Prueba/rss.aspx);

// return a new DataSet
DataSet ds = new DataSet();
ds.ReadXml(reader);
}
catch
{
throw;
}
finally
{
if(reader!=null)
reader.Close();
}
Da un WebException - "error en el servidor alejado: (401) nonauthorized "y
no entiendo porque.
¿Que sucede? ¿Porque puede ser leído en otros usos y no en el mismo sitio
del Web?
Un saludo y gracias.
Marcos

Re: ReadXml (DataSet) and WebException (401) Paul Glavich [MVP ASP.NET]
10/2/2005 3:31:05 PM
You need to use a HttpWebRequest something like (and this may not be 100%
correct):

HttpWebRequest rqst =
(HttpWebRequest)WebRequest.Create(http://localhost/Prueba/rss.aspx);
rqst.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse rsp = (HttpWebResponse)request.GetResponse ();
XmlTextReader rdr = new XmlTextReader(rsp.GetResponseStream());


--
- Paul Glavich
MVP ASP.NET
http://weblogs.asp.net/pglavich
ASPInsiders member - http://www.aspinsiders.com


[quoted text, click to view]

AddThis Social Bookmark Button