c# - 如何防止搜索引擎缓存提供的自定义处理程序 "text/plain"类型

标签 c# asp.net iis handler

我有一个 iis 处理程序,它为 .txt 文件提供 context.Response.ContentType = "text/plain"; 如何防止内容被 google 或任何搜索引擎缓存(应该允许索引,所以我不想将其添加到 robots.txt)?

有没有一种方法可以将 nocache header 添加到 context.Response.ContentType = "text/plain";

我有 context.Response.Cache.SetCacheability(HttpCacheability.NoCache); 但这不会阻止搜索引擎缓存内容。

最佳答案

该 header 控制客户端缓存,而不是搜索引擎缓存。你需要设置

  Response.AppendHeader("X-Robots-Tag", "noarchive");

Described here

Do not show a "Cached" link in search results.

关于c# - 如何防止搜索引擎缓存提供的自定义处理程序 "text/plain"类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27335261/

相关文章:

c# - 根据接口(interface)字符串名称实例化类

c# - 测试具有回调页面的 Web 应用程序

c# - 是否可以在 webforms 应用程序的 URL 路由中使用查询字符串

asp.net - 在 Orchard 中创建内容项时不显示内容部分编辑 View

c# - 如何在 <%# Eval "or")%> 内联语句中使用 ('column' 条件?

c# - 确保文本在 dataGridView 列中换行

c# - SOAP 错误 : "Server was unable to process request" "Object reference not set to an instance of an object"

asp.net - 我可以在 IIS 上部署 Azure 项目吗?

javascript - Angular 的 PRE-Gzipped 文件不是通过 IIS 提供的吗?

c# - 取消正在运行的进程