Is there a difference between an F5 browser refresh and postback??(asp.NET)

六月ゝ 毕业季﹏ 提交于 2019-12-01 00:59:08

It's simple, the browser caches the response. So if you press F5, you'd generally see your grid with the checked checkboxes each time. But if you do a post-back in code, you force the browser to connect to the server and post the data.

It will then wait for a response from the server, and return whatever the reason for the post-back was.

Annoying, but that's how browsers work. You can force a complete refresh than emulates a post-back by hitting Ctrl+F5.

This is (sometimes) browser dependent because not all browsers will act the same as you described here.

If a post-back is necessary but you still want to keep the checkbox status as checked, I'd recommend an AJAX call instead.

A "Refresh" simply calls the last request made for a page. So, if you just browsed to a page then hit refresh, it simply asks for that page again.

A Postback is essentially an action on the page that sends information back to the server.

Ideally it is a PostBack but it will depend on your Browser Settings if you have set it to Request page from Server for every visit or it picks from the Local Histroy Cache.

Hitting the Refresh button will make a new request to the page from the server , and it will not change the status of the Http Method(Get , Post) , I mean it will not change the IsPostBack status for the page.

However submitting the form(posting the form) will set the IsPostBack property to true and about page_load it will be called for both of the cases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!