网站内容自动更新( 本文转自博客园张占岭张占岭)
优采云 发布时间: 2021-10-17 06:40网站内容自动更新(
本文转自博客园张占岭张占岭)
namespace TestHttpModule
{
public class SEOModule : IHttpModule
{
#region IHttpModule 成员
public void Dispose()
{
throw new NotImplementedException();
}
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e)
{
var application = (HttpApplication)sender;
application.Context.Response.Expires = 0;
application.Context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
application.Context.Response.AddHeader("pragma", "no-cache");
application.Context.Response.AddHeader("cache-control", "private");
}
#endregion
}
}
对于目录网站,只需要在web.config中配置该模块即可。
并将这个module.dll直接复制到目标网站的bin目录下,运行后会自动加载网站。
其实通过这个.net应用的项目,我们可以开发出很多常用的模块,并结合具体的项目,实现具体项目的“功能热插拔”!
本文转自张展灵(仓储大叔)的博客,原文链接:基础是重中之重~bin目录下的程序集会自动加载,如需转载请自行联系原博主。