如何确定应用程序的Web应用程序 [英] How determine if application is web application
问题描述
在核心组件,这是在一个窗口服务同时运行,并在Web应用程序中,我需要存储每个用户的会话信息。这项服务将有一个单独的用户会话和Web应用程序使用HttpContext.Current。
我要配置的核心组件内使用哪种方法 - 约定优于配置。我想这样做只有一次,我相信HttpContext.Current将是无效的的Application_Start运行时。
我如何能够可靠地确定该应用程序是一个Web应用程序?
如果(HttpRuntime.AppDomainAppId!= NULL)
{
//为Web应用程序
}
其他
{
//是Windows应用程序
}
In a core assembly, which is run both in a windows service, and in a web application, I need to store information per user session. The service will have a single user session, and the web application uses HttpContext.Current.
I want to configure which method to use within the core assembly - convention over configuration. I want to do this only once, and I believe HttpContext.Current will be null when run from Application_Start.
How can I reliably determine if the application is a web application?
if(HttpRuntime.AppDomainAppId != null)
{
//is web app
}
else
{
//is windows app
}
这篇关于如何确定应用程序的Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!