我可以将IIS添加(注入)HTML到它所服务的每个页面吗? [英] Can I make IIS add (inject) HTML to every page it serves?

查看:484
本文介绍了我可以将IIS添加(注入)HTML到它所服务的每个页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在IIS 6服务器所服务的每个页面上添加一些HTML。它大部分都是静态HTML。这是IIS或扩展程序可以做的事情吗?我需要控制注入HTML的方式和位置,在这种情况下是在标记之前。感谢您的建议!

I would like to add some HTML to every page that our IIS 6 server serves. It's serving static HTML for the most part. Is this something IIS or an extension can do? I would need some control over how and where the HTML is injected, in this case before the tag. Thanks for your suggestions!

推荐答案

如果您熟悉ASP.NET,可以编写 HTTP响应过滤器这样做。

If you're familiar with ASP.NET, you could write a HTTP Response Filter to do that.

阅读 Milan Negovan的文章

HttpResponse 类有一个非常有用的属性:

The HttpResponse class has a very useful property:

public Stream Filter {get; set;}




MSDN提供
的有用说明property:获取或设置
包装过滤器对象,用于在
传输之前修改
HTTP实体主体。困惑?在其他
字样中,您可以为每个页面响应分配自己的自定义
过滤器。
HttpResponse将通过您的过滤器发送所有内容
。这个过滤器将在
回复给用户之前调用
,如果需要
,你将
进行转换以进行转换。

MSDN provides a helpful description of this property: "Gets or sets a wrapping filter object used to modify the HTTP entity body before transmission." Confused? In other words, you can assign your own custom filter to each page response. HttpResponse will send all content through your filter. This filter will be invoked right before the response goes back to the user and you will have a change to transform it if need be.

如果
需要转换遗留
代码的输出或替换占位符
(页眉,页脚,导航,你的名字为$ b),这可能会非常有用$ b it)使用正确的代码。此外,在b $ b $时,根据
规则,每个服务器控件都可以确保
,并且产生你期望的
。输入回复过滤器。

This could be extremely helpful if you need to transform output from "legacy" code or substitute placeholders (header, footer, navigation, you name it) with proper code. Besides, at times it's simply impossible to ensure that every server control plays by the rules and produces what you expect it to. Enter response filters.

过滤器属性的类型为
System.IO.Stream 。要创建自己的
过滤器,您需要从
System.IO.Stream(这是一个抽象的
类)派生一个类,并在其
多种方法中添加实现。

The Filter property is of type System.IO.Stream. To create your own filter you need to derive a class from System.IO.Stream (which is an abstract class) and add implementation to its numerous methods.

这篇关于我可以将IIS添加(注入)HTML到它所服务的每个页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆