我需要在Application_Start事件中访问网站网址。由于上下文中的HttpRequest无效,我无法检索URL。有没有其他方法可以检索应用程序的URL?
例如,我需要获取https://somehost/root/,假设应用程序在IIS中以root身份托管。
提前致谢
答案 0 :(得分:1)
尝试Application_AcquireRequestState:
void Application_AcquireRequestState(object sender, EventArgs e)
{
string url = Request.Url.ToString();
}