I am trying to a redirect the user when they click on a specific button
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("ControlPanel/Default.aspx");
}
The problem is when I click Button1 it redirects me to another page
localhost:57988/WebSite5/Default.aspx
and the weirdest thing is it open another page with this link above, not the default page I have, but another but with the default.aspx page url that you see!
Any suggestions?
You are not doing a redirect, you are doing a transfer. That means that the execution continues with the new page, but the URL doesn’t change. The page that you transferred to is returned as response to the request for the first page.
Use
Response.Redirectinstead ofServer.Transferto do a redirect.