-1

Everyone,I must launch my code, The first way:

Response.Write("<script>alert('Succeed,Will be redirect to the target page')</script>");
string path = Server.MapPath(@"~\Forms\MainForm_SQL.aspx");
Response.Redirect(path);

The second way:

Response.Write("<script>alert('Succeed,Will be redirect to the target page')</script>");
Server.Transfer(@"~\Forms\MainForm_SQL.aspx");

Now,back to the issue,The question is :

01)it works nothing when using the 'first way',That is, it either alerts the message nor goes into the 'Page_Load' of the target page.

02),when use the second way,it first goes into the 'Page_Load' of the target,than it goes back to alert the message.

why it that so unreachable to track the architecture ? can some one help me please? thanks.

afzalulh
  • 7,925
  • 2
  • 26
  • 37
Telerik
  • 167
  • 9

1 Answers1

1

IIRC, Server.Transfer is internal -- that is, it hands off processing to the destination without bouncing the client to another page -- whereas Response.Redirect tells the client to go to the new URL.

cHao
  • 84,970
  • 20
  • 145
  • 172
  • Thanks for your response,but would you give an explanation that,why many times, it doesn't work by Response.Redirect? or something wrong with the syntax?even when i just comment the< Response.Write(""); – Telerik Dec 25 '13 at 16:16
  • `Response.Redirect` basically tells the client to submit a request elsewhere. But that second request might not include all the form variables and such. If you're counting on them to be there... – cHao Dec 25 '13 at 17:31
  • Thanks for your response,but it seems that you did not got what I said the second time,actually,I found the question myself and That' manual mistake,I rename the .aspx file,but the actual name does not change unless I rename again in the code-behind.The first answer that you gave really help me,and thanks very much. – Telerik Dec 26 '13 at 05:43