在浏览器中刷新页面而不重新提交表单
我是一名 ASP.NET 开发人员,我通常会发现自己正在浏览器中打开正在处理的网页(Chrome 是我选择的浏览器,但这个问题与任何浏览器都相关)。我的工作流程通常是这样的:编写代码,在 Visual Studio 中重建项目,然后使用 Alt-Tab 翻回浏览器并按 F5 刷新页面。
如果自页面打开后尚未提交表单,这很好。但是,如果我一直在 ASP.NET 表单控件上单击,页面已多次发布表单数据,因此按 F5 会导致浏览器(明智地)弹出一条确认消息,例如“确认表单重新提交:您正在查找您输入的已使用信息的页面...”。
有时我确实想要重新提交表单,但更多时候,我只想重新开始页面(而不是重新提交表单数据)。我通常解决这个问题的方法是简单地向 URL 添加一些查询字符串数据,以便浏览器将其视为新的页面请求,例如:
page.aspx
变为
page.aspx?
(或反之亦然)。
我的问题是:是否有更好的方法可以在任何主要浏览器中快速请求网页的新版本(并且不提交表单数据)?对于网络开发来说,这对我来说似乎是理所当然的事情,但也许我错过了一些东西。我希望看到的是类似于此列表中的最后一项的内容:
- F5:刷新页面
- Ctrl-F5:刷新页面(并强制刷新缓存)
- Alt-F5:请求页面的新副本而不重新提交表单
I'm an ASP.NET developer, and I usually find myself leaving the webpage that I'm working on open in my browser (Chrome is my browser of choice, but this question is relevant for any browser). My workflow typically goes like this: I write code, I rebuild my project in Visual Studio, and then I flip back to my browser with Alt-Tab and hit F5 to refresh the page.
This is fine and dandy if a form hasn't been submitted since the page was opened. But if I've been clicking around on ASP.NET form controls, the page has posted form data a number of times, so hitting F5 causes the browser to (sensibly) pop up a confirmation message, e.g., "Confirm Form Resubmission: The page that you're looking for used information that you entered...".
Sometimes I do want to resubmit the form, but more often than not, I just want to start over with the page (rather than resubmit form data). The way I usually get around this is to simply add some query string data to the URL so that the browser sees it as a fresh page request, e.g.:
page.aspx
becomes
page.aspx?
(or vice-versa).
My question is: Is there a better way to quickly request a fresh version of a webpage (and not submit form data) in any of the major browsers? It seems like a no-brainer to me for web development, but maybe I'm missing something. What I'd love to see is something like the last item in this list:
- F5: refresh page
- Ctrl-F5: refresh page (and force cache refresh)
- Alt-F5: request fresh copy of the page without resubmitting the form
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
转到地址栏并按 Enter 提交新的 GET 请求。快速键盘快捷键是 Alt+D、Enter。
Go to the address bar and press Enter to submit a fresh GET request. Quick keyboard shortcut is Alt+D, Enter.
是的,只需关注地址栏并按 Enter 键即可。
在 Chrome 中,您可以使用 Ctrl-L 来关注地址栏以及上面提出的建议。
Yes, just focus on address bar and press enter.
In Chrome, you can use Ctrl-L to focus on the address bar as well as the suggestions made above.