Server.Transfer 与浏览器刷新
我在asp.net中创建了两个表单,分别是test1.aspx和test2.aspx。 test1 页面包含一个提交按钮。如果用户单击此按钮,我会使用 server.transfer 方法转移到 test2 页面。在这种情况下,浏览器将显示test2页面内容,但浏览器的地址栏将显示test1页面位置。当用户点击浏览器刷新按钮或者F5时,test1页面起作用,提交按钮起作用。我不想做这个工作我想刷新 test2 页面。我怎么能这么做呢?我不想使用response.redirect。
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 or 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请改用 Response.Redirect。这实际上会重定向到 test2.aspx,因此刷新将刷新 test2.aspx。
Use Response.Redirect instead. This will actually redirect to test2.aspx so refresh will refresh test2.aspx.
您需要缓存您上次查看的页面(Session = Page2),因此当 Page1 重新加载时,它可以查看缓存,确定它位于错误的位置,然后再次进行 server.transfer。
但是,可能值得重新考虑此页面的工作方式,您是否考虑过使用单个页面并将页面状态存储在隐藏字段中
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