How do I determine if the executing assembly is a web app or winform/console?

后端 未结 5 1654
灰色年华
灰色年华 2021-01-18 02:14

I would like to write a helper function which build the exception message to write to a log. The code look like:

if(IsWebApp)
{

    &

5条回答
  •  离开以前
    2021-01-18 03:16

    Use the HttpRuntime class:

    if (!String.IsNullOrEmpty(HttpRuntime.AppDomainAppVirtualPath))
        //ASP.Net
    else 
        //Non-ASP.Net
    

提交回复
热议问题