0

I have two web site Web1 and Web2 on same server and same IIS.

Is there any way I can do Server.Transfer() to get Web2 site Page from Web1 site.

Web1 Site code:

    protected void btnGoToWeb2Page_Click(object sender, EventArgs e)
    {
       Server.Transfer("http://localhost:84/Home.aspx");
    }

This is not working. Please help.

1 Answers1

0

Server. Trasfer works only for pages within the same website. If you want to transfer to another website you need to use Response. Redirect as in code below.

Response.Redirect("http://localhost/website2/somepage.aspx")
Sunil
  • 20,653
  • 28
  • 112
  • 197
  • Thanks for reply. I know I can do Response.Redirect to redirect to other website page on same app server. Is there any way I can do Server.Transfer() to get Web2 site Page from Web1 site. – user3540425 Dec 01 '17 at 09:55
  • No. Server.Transfer uses the current HttpContext and each website will have its own context in which it runs. One way, which you could try, is have another page called `ipage.aspx` in the same website `website1` as original page. In this page, add an iframe with `src='http://localhost:84/Home.aspx` and make sure the iframe fills the full page in browser. Then in your C# code when you say `Server.Transfer(http://localhost/website1/ipage.aspx')` it will automatically render your other website page. – Sunil Dec 01 '17 at 10:13