Click here to Skip to main content
15,883,888 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a simple 2 pages web site for test on host,
in first page i have a button and it's code is redirect to second page.
it works fine by iis on my computer but when i upload it to host, the page refresh and returns to first page and does not redirect.
it seems just page load method works.
how can i solve it?
Posted
Comments
Peter Leow 7-Feb-15 3:29am    
show code.
hamid6243 7-Feb-15 4:36am    
first page code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>


***********************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("default2.aspx");
}
}

****************************
second page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
second page
</div>
</form>
</body>
</html>
Afzaal Ahmad Zeeshan 7-Feb-15 3:30am    
How do you redirect? Are you using

Response.Redirect("~/second-page.cshtml");

Please add a few more details to the question.
/\jmot 7-Feb-15 4:03am    
Its not error of redirection, you just said that it returns to the previous page from the next page, so check the redirect page code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900