I don't know the below method is same as Java filter.
This problem was solved using HTTPModule.
I implemented below source and customized web.config.
Is this OK?
App_Code/TimeJudge.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class TimeJudge : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += new EventHandler
(this.OnBeginRequest);
}
private void OnBeginRequest(Object source, EventArgs e)
{
string nowTime = DateTime.Now.ToString("HHmm");
string startTime = System.Configuration.ConfigurationManager.AppSettings[WebConfigKey.StartTime.ToString()];
string endTime = System.Configuration.ConfigurationManager.AppSettings[WebConfigKey.EndTime.ToString()];
if (nowTime.CompareTo(startTime) > 0 && nowTime.CompareTo(endTime) < 0)
{
return;
}
HttpApplication application = (HttpApplication)source;
if (application.Request.Url.AbsoluteUri.EndsWith(".ASPX") && !application.Request.Url.AbsoluteUri.EndsWith("STOP.ASPX"))
application.Response.Redirect("~/STOP.ASPX");
}
public void Dispose()
{
}
}
web.config
<configuration>
<system.web>
<httpmodules>
<add name="TimeJudge" type="TimeJudge" />
</httpmodules>
</system.web>
<appsettings>
<!--
<add key="StartTime" value="0730" />
<add key="EndTime" value="2159" />
</appsettings>
</configuration>