Detect site login url in Application_End

孤街浪徒 提交于 2019-12-12 18:27:32

问题


I have this entry in web.config

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

I have the below code in Global.asax.cs to automatically start the IIS when it is recycle

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;
        }
    }

My Question is can I detect the application forms authentication login page url in Application_End method some how? Instead of reading entry from <appSettings/>

Note: I am using Quartz.Net in my MVC4 application and it is stop working when IIS recycle. I read IIS app pool recycle + quartz scheduling and many SO links but no use. We use external hosting provider, so we dont have a control of changing a physical config file.

After reading http://weblog.west-wind.com/posts/2007/May/10/Forcing-an-ASPNET-Application-to-stay-alive I decided to go with this solution.


回答1:


Check out the MSDN docs on FormsAuthentication.LoginUrl.

If you have your forms authentication set up in web.config's <authentication> element, and you have the "loginURL" populated there, then the property mentioned above should have the information you're looking for.



来源:https://stackoverflow.com/questions/24326172/detect-site-login-url-in-application-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!