Page Refresh Returns to previous page
I am using server.transfer to redirect from one to another page... lets say when i click on button1 of page1 i redirects to page2 using server.transfer but than when i refresh that page2 , it get postback and redirects me page1 again.. please tell me where i am doing wrong.? I have tried with both.. but result is same
server.Transfer("~/admin/mypage.aspx?msg开发者_开发问答=A",False )
server.Transfer("~/admin/mypage.aspx?msg=A",True )
When you use Server.Transfer
, the browser will not know that you are showing page2, it still thinks that you are showing page1. This is the reason why the browser will refresh page1 instead of page2.
If you use Response.Redirect
instead, the server will explicitly tell the browser to load page2 and shouldn't have this problem anymore.
There are several articles explaining the difference between Server.Transfer
and Response.Redirect
, you can find some on google.
精彩评论