代码之家  ›  专栏  ›  技术社区  ›  Matthew Vines

.net在运行时确定我的应用程序是exe还是web应用程序

  •  3
  • Matthew Vines  · 技术社区  · 15 年前

    2 回复  |  直到 12 年前
        1
  •  7
  •   Nathan Ridley    15 年前

    bool isWebApp = HttpContext.Current != null;
    

    每次都很有魅力。

        2
  •  4
  •   M4N    13 年前

    我终于找到了早些时候做这件事的方法。

    bool isWebApp = System.Web.HttpRuntime.AppDomainId != null;
    

    不过,这和内森的回答差不多。谢谢你的回复。