What is the code required to redirect the browser to a new page with an ASPX page?
I have tried this on my page default.aspx :
<% Response.Redirec
In a special case within ASP.NET If you want to know if the page is redirected by a specified .aspx page and not another one, just put the information in a session name and take necessary action in the receiving Page_Load Event.
Redirect aspx :
<iframe>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.avsapansiyonlar.com/altinkum-tatil-konaklari.aspx");
}
</script>
</iframe>
Or you can use javascript to redirect to another page:
<script type="text/javascript">
function toRedirect() {
window.location.href="new.aspx";
}
</script>
Call this toRedirect()
function from client (for ex: onload event of body tag) or from server using:
ClientScript.RegisterStartupScript(this.gettype(),"Redirect","toRedirect()",true);
<%@ Page Language="C#" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
Response.Redirect("new.aspx");
}
</script>
Even if you don't control the server, you can still see the error messages by adding the following line to the Web.config file in your project (bewlow <system.web>
):
<customErrors mode="off" />
If you are using VB, you need to drop the semicolon:
<% Response.Redirect("new.aspx", true) %>