Solved Server side include or similiar thing - How ?

Posted on 2005-04-21
Last Modified: 2010-04-07
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.
Question by:Dineth
    LVL 2

    Accepted 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)
    LVL 1

    Author Comment

    Hi SThorogood
    BIG THANK to you !!
    it works

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now