gpt4 book ai didi

c# - 在 Application_End 中检测站点登录 url

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:44 26 4
gpt4 key购买 nike

我在 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/> 中读取条目

注意:我在我的 MVC4 应用程序中使用 Quartz.Net,它在 IIS 回收时停止工作。我读了IIS app pool recycle + quartz scheduling和许多 SO 链接但没有用。我们使用外部托管服务提供商,因此我们无法控制更改物理配置文件。

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

最佳答案

FormsAuthentication.LoginUrl 上查看 MSDN 文档.

如果您在 web.config 的 <authentication> 中设置了表单例份验证元素,并且您在那里填充了“loginURL”,那么上述属性应该包含您要查找的信息。

关于c# - 在 Application_End 中检测站点登录 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24326172/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com