Get HTML Content of a Local Page

S

Sam

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
 
G

Gozirra

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))
 
S

Sam

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
 
G

Gozirra

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top