防止用户继续浏览我的网站信息
我想阻止我的网站将任何信息放入任何用户的浏览器历史记录中。 我正在使用 asp .net 来构建我的网站。知道我该如何执行此操作吗?
I want to prevent my website from putting any information in the browser history of any user.
I am using asp .net to build my website. Any idea how can i perform this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不可能。这是客户端设置,无法从服务器端进行控制。如果可能的话,这也将是一个严重的安全漏洞。
编辑:根据评论和帖子,您确实要禁用请求缓存吗?如果是这样,那么您基本上需要在相关页面的 HTML
中添加以下一组响应标头:
我不使用 ASP.NET,但您必须能够以编程方式执行类似操作。检查
response
对象,它应该有一个类似于setHeader(name, value)
的方法。然而,这仍然无法阻止页面的 URL 出现在浏览器历史记录中。
Not possible. That's a client side setting which is in no way controllable from the server side on. If it was possible, it would have been a serious security hole as well.
Edit: According to the comments and posts, do you actually want to disable the caching of the requests? If so, then you basically need to add the following set of response headers in the HTML
<head>
of the pages in question:I don't do ASP.NET, but you must be able to do similar programmatically. Check the
response
object, it should have a method something likesetHeader(name, value)
.That however still doesn't prevent the URL's to the pages from appearing in the browser history.
除了为什么要这样做这个明显的问题之外,我认为您将很难从服务器端将信息保留在浏览器之外。
您可能想查看有关 HTML 元标记 的页面并查看元标记的 CACHE-CONTROL 和 PRAGMA NO-CACHE 选项。
祝你好运,希望这会有所帮助。
Other than the obvious question of why you would want to do this, I think you're going to have a very difficult time keeping information out of a browser from the server side of things.
You might want to to take a look at this page about HTML Meta Tags and look into the CACHE-CONTROL and PRAGMA NO-CACHE options of the meta tag.
Good luck, and hope this helps.
一些网站通过在 flash、silverlight、Javascript 或其他一些应用程序框架中创建网站来实现此目的,这些框架将 URL 与显示的内容分离。
如果做得仔细,您可以向用户展示所有内容并提供“正常”的浏览体验,但他们在历史记录中看到的唯一内容就是一个 URL。
如果您想避免任何数据保留在客户端上,则需要更加小心。 AJAX 请求可能会被缓存。如果您想更仔细地控制缓存,以便数据永远不会写入磁盘,您可能必须使用 Flash 或 Silverlight,并且这些也存在陷阱。有很多方法可以解决这个问题(例如不使用 HTTP),但从客户端和服务器的角度来看,它都变得更加困难。
Some websites do this by creating their website within flash, silverlight, Javascript or some other application framework that disassociates the URL from the displayed content.
If done carefully you can present all your content to the user and provide a 'normal' browsing experience, but the only thing they'll see in their history is one URL.
If you want to avoid any data staying on the client, you'll need to be more careful. AJAX requests may be cached. You may have to use Flash or Silverlight if you want to control caching more carefully so data is never written to disk, and there are pitfalls in those as well. There are ways around it (such as not using HTTP) but it becomes more difficult from both a client and server perspective.
当然。始终导航到相同的 aspx 页面并根据 POST 参数动态显示内容。
Sure. Always navigate to the same aspx page and display the contents dynamically based on the POST parameters.
从 CSS 样式表中删除所有 a:visited 规则。
Remove any a:visited rules from your CSS stylesheet.
将您网站上的所有链接设置为点击同一 URL 的 POST 请求。该页面将是一个返回真实页面的简单 asp 页面。请注意,这不仅仅会阻止您的网站拥有正确的历史记录,还会产生副作用。这些可能是也可能不是可接受的效果。
Make all links on your site into POST requests hitting the same URL. That page will be a simple asp page which returns the real page. Note that this has side effects beyond merely preventing your site from having a proper history. These may or may not be acceptable effects.