How to find out if the current application is an ASP.NET web app

后端 未结 4 1118
Happy的楠姐
Happy的楠姐 2021-02-01 08:05

From a managed class library, I\'d like to find out whether the currently executing application is an ASP.NET web application (web forms or MVC) or not.

I have seen diff

4条回答
  •  后悔当初
    2021-02-01 08:50

    This might be helpful:

    How can I detect if my .NET assembly is running from web site or from a desktop machine?

    if(HttpRuntime.AppDomainAppId != null)
    {
      //is web app
    }
    else
    {
      //is windows app
    }
    

提交回复
热议问题