ReadXml (DataSet) and WebException (401)

Discussion in 'ASP .Net Security' started by Marcos Martínez, Sep 26, 2005.

  1. 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
     
    Marcos Martínez, Sep 26, 2005
    #1
    1. Advertising

  2. 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


    "Marcos Martínez" <marcos@#¡QUITAESTO!#villamalea.com> wrote in message
    news:dh918f$oec$-data.net...
    >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
    >
     
    Paul Glavich [MVP ASP.NET], Oct 2, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. San

    WebException: error: (401)

    San, Jul 7, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    387
  2. Replies:
    0
    Views:
    4,193
  3. Marcos Martínez

    ReadXml (DataSet) and WebException (401)

    Marcos Martínez, Sep 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,597
    Paul Glavich [MVP ASP.NET]
    Oct 2, 2005
  4. MattB
    Replies:
    7
    Views:
    773
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    May 16, 2007
  5. Felipe Blin

    BUG?:using dataset and ReadXML in postback

    Felipe Blin, Jul 15, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    173
    Felipe Blin
    Jul 15, 2004
Loading...

Share This Page