asp.netserver.transfer

How can I do Server.Transfer() to get Web2 site Page from Web1 site


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.


Solution

  • 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")