WebRequest

Discussion in 'ASP .Net' started by =?Utf-8?B?TE9MTw==?=, Jul 17, 2004.

  1. I want to save in a file the HTML code generated by a WebRequest to an aspx page.

    When a connect to a external site, i can obtain the html code generated by server. But when i connect to a page of my application, the server responds "(401) Non autorisé. "

    the is:

    WebRequest request=WebRequest.Create("http://localhost/software/tools/pages/index.htm");
    WebResponse response=request.GetResponse();
    Stream stream=response.GetResponseStream();

    the error is on the "WebResponse response=request.GetResponse();" only if the page is an aspx page in my code but never on an external site ...
     
    =?Utf-8?B?TE9MTw==?=, Jul 17, 2004
    #1
    1. Advertising

  2. Try using the IP address of your local machine instead of "localhost."

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "LOLO" <> wrote in message
    news:...
    > I want to save in a file the HTML code generated by a WebRequest to an

    aspx page.
    >
    > When a connect to a external site, i can obtain the html code generated by

    server. But when i connect to a page of my application, the server responds
    "(401) Non autorisé. "
    >
    > the is:
    >
    > WebRequest

    request=WebRequest.Create("http://localhost/software/tools/pages/index.htm")
    ;
    > WebResponse response=request.GetResponse();
    > Stream stream=response.GetResponseStream();
    >
    > the error is on the "WebResponse response=request.GetResponse();" only if

    the page is an aspx page in my code but never on an external site ...
    >
    >
     
    Kevin Spencer, Jul 17, 2004
    #2
    1. Advertising

  3. thank you for this idea but it's the same problem.
    do you know another way to get the server generated html code ?

    from inside the form (using response variable) or from an external request ?

    "Kevin Spencer" wrote:

    > Try using the IP address of your local machine instead of "localhost."
    >
    > --
    > HTH,
    > Kevin Spencer
    > ..Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "LOLO" <> wrote in message
    > news:...
    > > I want to save in a file the HTML code generated by a WebRequest to an

    > aspx page.
    > >
    > > When a connect to a external site, i can obtain the html code generated by

    > server. But when i connect to a page of my application, the server responds
    > "(401) Non autorisé. "
    > >
    > > the is:
    > >
    > > WebRequest

    > request=WebRequest.Create("http://localhost/software/tools/pages/index.htm")
    > ;
    > > WebResponse response=request.GetResponse();
    > > Stream stream=response.GetResponseStream();
    > >
    > > the error is on the "WebResponse response=request.GetResponse();" only if

    > the page is an aspx page in my code but never on an external site ...
    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?TE9MTw==?=, Jul 17, 2004
    #3
  4. It's a 401 error, which is "unauthorized." It sounds like your app may
    require a login (disallow anonymous requests)?

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "LOLO" <> wrote in message
    news:...
    > thank you for this idea but it's the same problem.
    > do you know another way to get the server generated html code ?
    >
    > from inside the form (using response variable) or from an external request

    ?
    >
    > "Kevin Spencer" wrote:
    >
    > > Try using the IP address of your local machine instead of "localhost."
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > ..Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "LOLO" <> wrote in message
    > > news:...
    > > > I want to save in a file the HTML code generated by a WebRequest to an

    > > aspx page.
    > > >
    > > > When a connect to a external site, i can obtain the html code

    generated by
    > > server. But when i connect to a page of my application, the server

    responds
    > > "(401) Non autorisé. "
    > > >
    > > > the is:
    > > >
    > > > WebRequest

    > >

    request=WebRequest.Create("http://localhost/software/tools/pages/index.htm")
    > > ;
    > > > WebResponse response=request.GetResponse();
    > > > Stream stream=response.GetResponseStream();
    > > >
    > > > the error is on the "WebResponse response=request.GetResponse();" only

    if
    > > the page is an aspx page in my code but never on an external site ...
    > > >
    > > >

    > >
    > >
    > >
     
    Kevin Spencer, Jul 17, 2004
    #4
  5. =?Utf-8?B?TE9MTw==?=

    Scott Allen Guest

    If you need to login with forms authentication, I have an article
    covering this topic here:

    http://odetocode.com/Articles/162.aspx

    --
    Scott

    On Sat, 17 Jul 2004 08:27:02 -0700, "LOLO"
    <> wrote:

    >I want to save in a file the HTML code generated by a WebRequest to an aspx page.
    >
    >When a connect to a external site, i can obtain the html code generated by server. But when i connect to a page of my application, the server responds "(401) Non autorisé. "
    >
    >the is:
    >
    >WebRequest request=WebRequest.Create("http://localhost/software/tools/pages/index.htm");
    >WebResponse response=request.GetResponse();
    >Stream stream=response.GetResponseStream();
    >
    >the error is on the "WebResponse response=request.GetResponse();" only if the page is an aspx page in my code but never on an external site ...
    >
    >


    --
    Scott
    http://www.OdeToCode.com
     
    Scott Allen, Jul 18, 2004
    #5
  6. It feel like when you try to refresh the page using 'F5'--> you have to repost the data.
    I think when i try to open the response request , i should have to close something into the current page but i d'ont know what. some on have an idea ?

    "Kevin Spencer" wrote:

    > It's a 401 error, which is "unauthorized." It sounds like your app may
    > require a login (disallow anonymous requests)?
    >
    > --
    > HTH,
    > Kevin Spencer
    > ..Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "LOLO" <> wrote in message
    > news:...
    > > thank you for this idea but it's the same problem.
    > > do you know another way to get the server generated html code ?
    > >
    > > from inside the form (using response variable) or from an external request

    > ?
    > >
    > > "Kevin Spencer" wrote:
    > >
    > > > Try using the IP address of your local machine instead of "localhost."
    > > >
    > > > --
    > > > HTH,
    > > > Kevin Spencer
    > > > ..Net Developer
    > > > Microsoft MVP
    > > > Big things are made up
    > > > of lots of little things.
    > > >
    > > > "LOLO" <> wrote in message
    > > > news:...
    > > > > I want to save in a file the HTML code generated by a WebRequest to an
    > > > aspx page.
    > > > >
    > > > > When a connect to a external site, i can obtain the html code

    > generated by
    > > > server. But when i connect to a page of my application, the server

    > responds
    > > > "(401) Non autorisé. "
    > > > >
    > > > > the is:
    > > > >
    > > > > WebRequest
    > > >

    > request=WebRequest.Create("http://localhost/software/tools/pages/index.htm")
    > > > ;
    > > > > WebResponse response=request.GetResponse();
    > > > > Stream stream=response.GetResponseStream();
    > > > >
    > > > > the error is on the "WebResponse response=request.GetResponse();" only

    > if
    > > > the page is an aspx page in my code but never on an external site ...
    > > > >
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?TE9MTw==?=, Jul 19, 2004
    #6
    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. CodeMotion
    Replies:
    0
    Views:
    557
    CodeMotion
    Jul 3, 2003
  2. Andres
    Replies:
    2
    Views:
    6,643
    Natty Gur
    Aug 14, 2003
  3. Sujith Jagini

    problem with webRequest.method = post

    Sujith Jagini, Aug 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,491
    Natty Gur
    Aug 17, 2003
  4. John Saunders

    Re: problem with webRequest.method = post

    John Saunders, Aug 20, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    415
    John Saunders
    Aug 20, 2003
  5. Christian Pické

    WebRequest

    Christian Pické, Oct 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    639
    Oliver
    Oct 22, 2003
Loading...

Share This Page