Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从ASP.NET Core 3调用使用Windows身份验证的API_C#_Api_Authentication_Asp.net Core_Windows Authentication - Fatal编程技术网

C# 从ASP.NET Core 3调用使用Windows身份验证的API

C# 从ASP.NET Core 3调用使用Windows身份验证的API,c#,api,authentication,asp.net-core,windows-authentication,C#,Api,Authentication,Asp.net Core,Windows Authentication,所以我在ASP.NET Core 3中有一个Windows身份验证Web应用程序。它是默认生成的,并且启用了Windows身份验证(创建时勾选“Windows身份验证框”)。当API使用Windows身份验证时,如何访问API并获取其资源(本例中为Json对象)? 我已经将此添加到launchSettings.json中: "windowsAuthentication": true, "anonymousAuthentication": false, 我将其添加到web.config文件中,以

所以我在ASP.NET Core 3中有一个Windows身份验证Web应用程序。它是默认生成的,并且启用了Windows身份验证(创建时勾选“Windows身份验证框”)。当API使用Windows身份验证时,如何访问API并获取其资源(本例中为Json对象)? 我已经将此添加到launchSettings.json中:

"windowsAuthentication": true,
"anonymousAuthentication": false,
我将其添加到web.config文件中,以便稍后托管,但我认为这并不重要,因为我希望在Visual Studio中本地运行它:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <security>
        <authentication>
          <anonymousAuthentication enabled="false" />
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>
    </system.webServer>
  </location>
</configuration>


如何让我的应用程序提示用户使用其凭据登录以验证对api数据的访问(使用Windows身份验证)?

这些用户是否在同一Windows域中?(否则,为您站点的每个用户创建本地Windows用户将非常困难…而且几乎没有人知道如何登录到不同的Windows域)我不确定我是否正确,您是否希望通过Windows身份验证保护您的api,或者您希望将凭据传递给的另一个API?您是询问直接从浏览器访问API,还是从其他Web项目的服务器端访问API?如果他们已经在PC上登录到域,则不应要求他们再次登录以进行API访问(如果他们直接从浏览器访问)