【问题标题】:Cant add IdentityServer4 to ASP.NET Framework 4.7.2 API OWIN无法将 IdentityServer4 添加到 ASP.NET Framework 4.7.2 API OWIN
【发布时间】:2019-08-22 21:22:39
【问题描述】:

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

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

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

这是我的启动课:

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);
    }

}

这是我的项目的link

我这几天一直在寻找解决方案,但找不到任何有用的方法。如果我遗漏了什么,请见谅。

谢谢。

【问题讨论】:

  • Idsrv4 是一个开箱即用的 aspnetcore 解决方案,所以我说将 idsrv3 用于网络框架

标签: asp.net oauth-2.0 identityserver4 .net-standard-2.0


【解决方案1】:

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

<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。

【讨论】:

    猜你喜欢
    • 2021-02-06
    • 2013-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-28
    • 1970-01-01
    • 2015-03-09
    • 2018-12-04
    相关资源
    最近更新 更多