[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Asp.net Server side include or similiar thing - How ?

Hi All,

My requirement is like this. I have a page. From this page and get some values from the user and then compose a url and on the client side I make a request to  the second web server(a different domain) and display a report page in a pop-up window.

But We have planned disallow direct access to the second web server from client machine, and only allow access from the first web server only, hence the current way cannot be used anymore.

What I have thought of was have a second .aspx page in the first web server and then, from the first page I compose and pass the url  to the second page.Then on the server the content of the passed url is retrieved and displayed on the second page.So Second web server is accessed only from the first web server.

But still I couldn't achieve what I want. With Response.WriteFile(<url>) in the second page has also failed since the <url> shold be a relative path,but in my case I can't use relative paths since the page is from another web server.
Can't use <iframe> also since then again request is made from the client side.

I have used msxml component to somewhat similiar kind of thing(although it's not 100% the same) in ASP.

If Anybody can help me out on this, I would be really thankful.

Thanks in advance.
1 Solution
I suggest that you look at the System.Net namespace. In particular the




classes. To retrieve the content of a page on the second server use something like:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream, Encoding.ASCII);
responseText = reader.ReadToEnd();

You can probably even write the response stream directly to the Response.OutputStream of the requesting page. This would be an expensive operator to perform ever request, so you should also look at output caching the second page (use VaryByParam to cache multipel versions)
DinethAuthor Commented:
Hi SThorogood
BIG THANK to you !!
it works

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now