全局设置后台某个时间段不能发布信息
发布:apollo | 发布时间: 2009年10月13日国庆这段时间吧,遇到了一个比较有意思的事情,可能跟国内政府有关系吧,怕在国庆期间发布一些有害的文章,所以机房封网的封网,网站嘛可能是因为很多工作人员放假没有时间去管理,也都做了限制上传的操作。本来这个也是一个比较机械的活,不就是把后台给删除掉就可以了吗,但是仔细想想,国庆以后呢,那你还不是要一个一个的改回来,那不是又要一次重复的劳动,所以呢,我就在设想是不是可以通过一个全局的文件来实现,废话不多说,大家看看以下的代码,应该就会明白是什么意思了。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace WebApplication1
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
string FileName = HttpContext.Current.Request.FilePath.ToLower();
DateTime BTime = new DateTime(2009, 10, 1);
DateTime ETime = new DateTime(2009, 10, 9);
DateTime TTime = Convert.ToDateTime(DateTime.Now.ToString());
if (FileName.IndexOf("admin") > 0)
{
if ( BTime <= TTime && TTime <= ETime)
{
HttpContext.Current.Response.Write("国庆期间(10月1日-10月8日)封网,不允许进行信息发布操作。");
HttpContext.Current.Response.End();
}
}
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}
只要是在路径中包含有admin的信息的,就不能进去后台了,过了这个设定的时间网站一切恢复正常,呵呵~~~简单吧,当然这个代码还有再深度挖掘的必要,时间限制就没有去检测跟改进了,希望网友可以提出宝贵意见,谢谢啦。
- 相关文章:
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。





