【问题标题】:how to block web application based on date in asp.net?如何在 asp.net 中根据日期阻止 Web 应用程序?
【发布时间】:2012-11-24 16:06:28
【问题描述】:

我在 asp.net 中为我的客户开发了一个 Web 应用程序。该应用程序已托管在 Web 服务器中。如果我的客户不满足我的要求,我想根据日期阻止从服务器运行的 Web 应用程序。该怎么做?

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    您可以使用Application_BeginRequest 进行测试:

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
       string cTheFile = HttpContext.Current.Request.Path;
       string sExtentionOfThisFile = System.IO.Path.GetExtension(cTheFile);
       // here you can check what file you wish to cut, ether by file, ether by extention
       if (sExtentionOfThisFile.Equals(".aspx", StringComparison.InvariantCultureIgnoreCase))
       {
         // and here is the time limit.
         if(DateTime.UtcNow > MaxDateToUse)
         {
            HttpContext.Current.Response.TrySkipIisCustomErrors = true;
            HttpContext.Current.Response.StatusCode = 403;
            HttpContext.Current.Response.End();
            return ;    
        }    
      }
    }
    

    在 BasePage 中添加相同的测试,为所有页面使用该 BasePage,并按照我在此答案中描述的那样进行测试:Make an asp .net web app offline

    亲戚:
    Making a web site available only for a specified time
    switch off the all functions in .net service
    Make an asp .net web app offline

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-26
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      • 2016-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多