Get HTML Content of a Local Page

Discussion in 'ASP .Net' started by Sam, Nov 28, 2006.

  1. Sam

    Sam Guest

    Hi All,

    Is it possible to get a web page content of one of my webpages using
    relative path?

    for example:

    If I have a website which consists of 2 pages: testpage1.aspx and
    testpage2.aspx and the testpage2.aspx requires that I pass some parameters
    to populate its form. Now if I want to get the html content of
    "testpage2.aspx" page from testpage1's code behind page and store it in a
    string variable, is it possible? I have been using HttpWebRequest and
    HttpWebResponse objects to get the local page content but I just feel this a
    bit awkward. Also the method "Create" of System.Net.WebRequest.class
    requires a full url path to create a WebRequest object as in
    System.Net.WebRequest.Create(url). Thanks in advance for your help.

    Regards,

    Sam
    Sam, Nov 28, 2006
    #1
    1. Advertising

  2. Sam

    Gozirra Guest

    WebRequest would have been my suggestion but you are already doing it.
    Why do you need to retrieve the HTML from the page like this? What are
    you doing with the HTML?

    You can use a relative url if you pass it to the ResolveUrl function.
    System.Net.WebRequest.Create(ResolveUrl(url))


    Sam wrote:
    > Hi All,
    >
    > Is it possible to get a web page content of one of my webpages using
    > relative path?
    >
    > for example:
    >
    > If I have a website which consists of 2 pages: testpage1.aspx and
    > testpage2.aspx and the testpage2.aspx requires that I pass some parameters
    > to populate its form. Now if I want to get the html content of
    > "testpage2.aspx" page from testpage1's code behind page and store it in a
    > string variable, is it possible? I have been using HttpWebRequest and
    > HttpWebResponse objects to get the local page content but I just feel this a
    > bit awkward. Also the method "Create" of System.Net.WebRequest.class
    > requires a full url path to create a WebRequest object as in
    > System.Net.WebRequest.Create(url). Thanks in advance for your help.
    >
    > Regards,
    >
    > Sam
    Gozirra, Nov 28, 2006
    #2
    1. Advertising

  3. Sam

    Sam Guest

    Gozirra,

    We have a page which allows users to print mulitple documents via popup
    window at once by selecting checkbox beside them and the only way I can
    think of right now is to have each of the pages' content saved to a string
    and write to a popup


    "Gozirra" <> wrote in message
    news:...
    > WebRequest would have been my suggestion but you are already doing it.
    > Why do you need to retrieve the HTML from the page like this? What are
    > you doing with the HTML?
    >
    > You can use a relative url if you pass it to the ResolveUrl function.
    > System.Net.WebRequest.Create(ResolveUrl(url))
    >
    >
    > Sam wrote:
    >> Hi All,
    >>
    >> Is it possible to get a web page content of one of my webpages using
    >> relative path?
    >>
    >> for example:
    >>
    >> If I have a website which consists of 2 pages: testpage1.aspx and
    >> testpage2.aspx and the testpage2.aspx requires that I pass some
    >> parameters
    >> to populate its form. Now if I want to get the html content of
    >> "testpage2.aspx" page from testpage1's code behind page and store it in a
    >> string variable, is it possible? I have been using HttpWebRequest and
    >> HttpWebResponse objects to get the local page content but I just feel
    >> this a
    >> bit awkward. Also the method "Create" of System.Net.WebRequest.class
    >> requires a full url path to create a WebRequest object as in
    >> System.Net.WebRequest.Create(url). Thanks in advance for your help.
    >>
    >> Regards,
    >>
    >> Sam

    >
    Sam, Nov 28, 2006
    #3
  4. Sam

    Gozirra Guest

    I'd love to say that I have a great alternative solution for you but I
    don't. I would have solved the problem in the same manner that you
    are. I gave it some thought throughout the day and couldn't come up
    with an alternative. As long as there are no performance problems or
    any other issues, I believe the solution is pretty sound. Perhaps
    someone else in the forums has a better suggestion.

    Just to clarify, you are calling 1 - n different aspx pages in order to
    retrieve the results for display and not static data correct? For
    example, I want 2 reports for a given date range. The reports are
    generated on the fly by 2 separate aspx pages. I call the pages with
    the date parameters and the reports are generated on the fly. I
    display the reports in the popup window after I append the results into
    a single response.

    Sam wrote:
    > Gozirra,
    >
    > We have a page which allows users to print mulitple documents via popup
    > window at once by selecting checkbox beside them and the only way I can
    > think of right now is to have each of the pages' content saved to a string
    > and write to a popup
    >
    >
    > "Gozirra" <> wrote in message
    > news:...
    > > WebRequest would have been my suggestion but you are already doing it.
    > > Why do you need to retrieve the HTML from the page like this? What are
    > > you doing with the HTML?
    > >
    > > You can use a relative url if you pass it to the ResolveUrl function.
    > > System.Net.WebRequest.Create(ResolveUrl(url))
    > >
    > >
    > > Sam wrote:
    > >> Hi All,
    > >>
    > >> Is it possible to get a web page content of one of my webpages using
    > >> relative path?
    > >>
    > >> for example:
    > >>
    > >> If I have a website which consists of 2 pages: testpage1.aspx and
    > >> testpage2.aspx and the testpage2.aspx requires that I pass some
    > >> parameters
    > >> to populate its form. Now if I want to get the html content of
    > >> "testpage2.aspx" page from testpage1's code behind page and store it in a
    > >> string variable, is it possible? I have been using HttpWebRequest and
    > >> HttpWebResponse objects to get the local page content but I just feel
    > >> this a
    > >> bit awkward. Also the method "Create" of System.Net.WebRequest.class
    > >> requires a full url path to create a WebRequest object as in
    > >> System.Net.WebRequest.Create(url). Thanks in advance for your help.
    > >>
    > >> Regards,
    > >>
    > >> Sam

    > >
    Gozirra, Nov 28, 2006
    #4
    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. DigitalUncle
    Replies:
    0
    Views:
    884
    DigitalUncle
    Nov 2, 2004
  2. hazz
    Replies:
    6
    Views:
    49,394
    SkyUCHC
    Jun 9, 2010
  3. Lyndon
    Replies:
    1
    Views:
    505
    Leonard Blaisdell
    Jul 25, 2005
  4. Laith Zraikat
    Replies:
    3
    Views:
    1,195
    Walter Wang [MSFT]
    Jul 6, 2006
  5. Dave L
    Replies:
    3
    Views:
    3,171
    Göran Andersson
    Mar 4, 2010
Loading...

Share This Page