在我的WCF应用程序,我有一个Global.asax.cs中像这样的东西来获取基础URL:HttpContext.Current.Request空在生产
protected void Application_Start(object sender, EventArgs e)
{
string baseURL = System.Web.HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
}
在我的开发(本地主机)它工作正常。但是当我把它推到生产System.Web.HttpContext.Current.Request
返回null
。
任何人都知道为什么会发生这种情况?
是生产应用程序托管在IIS上。 – capdragon
你为什么试图在应用程序启动事件上使用当前请求?应用程序可能会或可能不会由请求启动。 –
@ liho1eye。卫生署!当然!我现在觉得很小,对不起,我应该删除这篇文章吗? – capdragon