本文介绍了无法将IdentityServer4添加到ASP.NET Framework 4.7.2 API OWIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ASP.NET Framework 4.7.2 WEB API中设置Identity Server 4 Auth服务器,但无法正常工作.我无法在Startup类中添加appBuilder.UseIdentityServer().

I'm trying to setup Identity Server 4 Auth server in ASP.NET Framework 4.7.2 WEB API, but I can't get it working. I'm not able to add appBuilder.UseIdentityServer() in the Startup class.

我的理解是IdentityServer4被编译为DotNet Standard 2.0,并且ASP.NET Framework 4.7.2与DotNet Standard 2.0兼容,因此IDS4应该可以在4.7.2项目中使用.请纠正我,如果我错了.

My understanding is that the IdentityServer4 is compiled as DotNet Standard 2.0 and the ASP.NET Framework 4.7.2 is compatible with DotNet Standard 2.0, so IDS4 should be able to be used inside 4.7.2 project. Correct me if I'm wrong please.

是否可以像这样使用IdentityServer4?我在这里做什么错了?

Is it possible to use IdentityServer4 like that?What am I doing wrong here?

这是我的入门班:

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        var builder = services.AddIdentityServerBuilder()
        .AddInMemoryIdentityResources(
            IdentityServerConfig.GetIdentityResources())
        .AddInMemoryApiResources(IdentityServerConfig.GetApis())
        .AddInMemoryClients(IdentityServerConfig.GetClients());
}

    public void Configuration(IAppBuilder appBuilder)
    {
        HttpConfiguration httpConfiguration = new HttpConfiguration();
        WebApiConfig.Register(httpConfiguration);
        appBuilder.UseWebApi(httpConfiguration);
    }

}

这是与我的项目的链接:

我一直在寻找解决方案,但是找不到任何帮助.如果我错过了什么,请问.

I've been looking for solution for couple of days, but I can't find anytning helpful. Excuse me if I've missed something.

谢谢.

推荐答案

如果问题是关于.NET Framework,而不是ASP.NET版本,则可以使用.NET 4.7.2.TestApi3.csproj必须看起来像:

In case the question is about .NET Framework, but not ASP.NET version, it is possible to use .NET 4.7.2.The TestApi3.csproj has to look like:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="IdentityServer4" Version="2.4.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
  </ItemGroup>

</Project>

然后它应该基于ASP.NET CORE MVC,而不是MVC 5.

Then it should work based on ASP.NET CORE MVC, not MVC 5.

这篇关于无法将IdentityServer4添加到ASP.NET Framework 4.7.2 API OWIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 02:57