开发者

Server.Transfer Vs refresh of the browser

开发者 https://www.devze.com 2023-04-01 04:45 出处:网络
I created two forms in asp.net, there are test1.aspx and test2.aspx. The test1 page contains one submit button. If the user clicks this, I do transfer to the test2 page by using server.transfer method

I created two forms in asp.net, there are test1.aspx and test2.aspx. The test1 page contains one submit button. If the user clicks this, I do transfer to the test2 page by using server.transfer method. In this situation, the browser will show the test2 page content but the address bar of the browser will show the test1 page location. When the user clicks the refresh button of the browser o开发者_JAVA百科r F5, the test1 page is worked and the submit button is worked. I don't want to work this. I want to refresh the test2 page. How could I do that? I don't want to use response.redirect.


Use Response.Redirect instead. This will actually redirect to test2.aspx so refresh will refresh test2.aspx.


You will need to cache which page you last looked at (Session = Page2), so when Page1 reloads, it can look at the cache, decide it's in the wrong place and then server.transfer again.

However it might be worth reconsidering how this page works, have you considered using a single page and storing the page state in a hidden fields

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号