在Application_End中检测站点登录url

本文关键字:检测站 站点 登录 url 检测 Application End | 更新日期: 2023-09-27 18:09:35

我在web.config中有这个条目

  <appSettings>
    <add key="pingUrl" value="http://examplesite.com/login.aspx"/>
  </appSettings>

我有下面的代码在Global.asax.cs自动启动IIS时,它是回收

void Application_End(object sender, EventArgs e)
    {
        try
        {
            string pingUrl = ConfigurationManager.AppSettings["pingUrl"];
            WebClient http = new WebClient();
            string Result = http.DownloadString(pingUrl);
        }
        catch (Exception ex)
        {
            string Message = ex.Message;
        }
    }

我的问题是我可以在Application_End方法中以某种方式检测应用程序表单认证登录页面url吗?而不是从<appSettings/>

读取条目

注意:我使用石英。Net在我的MVC4应用程序,它是停止工作时IIS回收。我读了IIS应用程序池回收+石英调度和许多SO链接,但没有使用。我们使用外部主机提供商,所以我们无法控制更改物理配置文件。

看完http://weblog.west-wind.com/posts/2007/May/10/Forcing-an-ASPNET-Application-to-stay-alive后,我决定采用这个解决方案

在Application_End中检测站点登录url

查看FormsAuthentication.LoginUrl上的MSDN文档。

如果您在web中设置了表单身份验证。配置的<authentication>元素,你有"loginURL"填充在那里,那么上面提到的属性应该有你正在寻找的信息。