【问题标题】:How to get Identity for app pool in web api controller如何在 Web api 控制器中获取应用程序池的标识
【发布时间】:2015-04-06 01:29:47
【问题描述】:

我有一个 web api 控制器,我需要获取在 IIS 中托管 web 应用程序的应用程序池的标识。

我试过了

string threadName = System.Threading.Thread.CurrentPrincipal.Identity.Name;
string username = this.User.Identity.Name;

但是两者都是空的。我想要运行 w3wp.exe 的名称,例如 IIS APPPOOL\DefaultAppPool 或 NETWORKSERVICE 或应用程序池配置为运行的任何名称。

在 VS2013 中创建新的 Wep Api 项目时使用默认的 authentication=none 进行了尝试,还尝试了 Forms auth,但没有成功。

【问题讨论】:

标签: c# asp.net iis asp.net-web-api


【解决方案1】:

在这个帖子上找到了答案:Get the Application Pool Identity programmatically

我在找

string appPoolName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-30
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    • 2015-01-21
    • 1970-01-01
    相关资源
    最近更新 更多