Response.Redirect和Server.Transfer面对页面刷新时的小区别

今天用Server.Transfer时遇到一个小问题,没有搜到相应的贴子记录,所以在此记录一下:

Server Transfer

  1. Client Request Page HelloWorld.ASPX
  2. Server.Transfer -> Server send a different page to the client
  3. Client Receives Page still thinking it's HelloWorld.ASPX.
  4. Client's URL (Address bar) remains HelloWorld.ASPX since the page was sent on the server side and the client doesn't know a different page was sent.

Response.Redirect

  1. Client Requests Page HelloWorld.ASPX
  2.  Response.Redirect -> Server sends a HTTP header informing that the user should redirect.
  3.  Client sees the redirect notice and requests AnotherPage.ASPX
  4.  Server sends AnotherPage.ASPX
  5. Client's URL (address bar) shows AnotherPage.ASPX

Server Transfer使用特殊注意事项:

  假如从A页面Transfer到B页面之后,在B页面刷新的话,此时会重新回到A页面的后台,进入A页面的点击事件然后再transfer到B页面。

如果A页面的点击事件有对数据库操作的话,此时就会再次操作数据库。为了数据安全还是Response.Redirect比较好。

转载于:https://www.cnblogs.com/michael110/archive/2011/03/03/1970163.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值