Is it possible to make a asp.net website available only during a particular time...? How to implement it..?
Yes you can do that using the BeginRequest on Global.asax
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if(!(DateTime.UtcNow.Hour >= 9 && DateTime.UtcNow.Hour <= 17))
{
HttpContext.Current.Response.TrySkipIisCustomErrors = true;
HttpContext.Current.Response.Write("Even if we are web site, we are open from 9.00 to 17.00 Only! :) <br />Ps If you are the google spider leave a message under the door.");
HttpContext.Current.Response.StatusCode = 403;
HttpContext.Current.Response.End();
return ;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With