Asaf wrote:
Hello,
I have a domain URL on a shared hosting server for example www.mydomain.com
When accessing www.mydomain.com I would like to get the ASPX files from
other domain on other server for example www.otherdomain.com but I would like
the URL on the browser for all the ASPX files will always stay on
www.mydomain.com so the one who browse my website will not see for example
www.otherdoamin.com/Default.aspx
Thanks in advanced for any advice.
Regards,
Asaf
In my understanding, you want to show an aspx file that is located in
different domain, but you don't want to show that domain name while its
get requested, rather you want to show as a content that is coming from
your own domain.
Pretty possible.
1. Create an ASPX page called "another_domain_info.aspx"
2. The below is the code that goes in the .aspx file
<body>
<form id="form1" runat="server">
<div id="yahooHtml" runat="Server"></div>
</form>
</body>
3. Now, in the another_domain_info.aspx.cs file create Page_Load event
and put the below code.
protected void Page_Load(object sender, EventArgs e)
{
WebRequest w = WebRequest.Create("http://www.yahoo.com");
WebResponse wr = w.GetResponse();
StreamReader r = new StreamReader (wr.GetResponseStream());
String html = r.ReadToEnd();
HtmlGenericControl DivElement = this.FindControl("yahooHtml")
as HtmlGenericControl;
DivElement.InnerHtml = html;
r.Close();
wr.Close();
}
4. Now press F5 to execute this code. You can see yahoo's home page in
the aspx file.
Basically, what happens is WebRequest object request the given url and
gets the response coming back from the server. After getting the
response we are binding the response which is html data to the div tag
kept in the .aspx file.
Let me know in case of any issues.
-
Vadivel Kumar
http://vadivelk.net