Website creation is only available for a specific time period
3 answers
Yes, you can do this using 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 ;
}
}
+4
source to share
Depending on what you want the site to look like when it's down, you can do it in different ways. One example would be creating a BasePage class and adding code to return a 404, or redirecting to an error page when the site should be down. Another option is to subscribe to the Application_BeginRequest event in Global.asax and do the same.
+1
source to share