1、通过自定义方法配置
1)在Startup中ConfigureServices方法中配置自定义方法SetupIdentityServer
services.AddIdentityServer(*SetupIdentityServer*) .AddSigningCredential(...) .AddValidationKeys() .AddConfigurationStore(builder => builder.UseSqlServer("")) .AddOperationalStore(builder => builder.UseSqlServer("")) .AddAspNetIdentity();
2)上面配置的SetupIdentityServer方法中配置登陆地址
private static void SetupIdentityServer(IdentityServerOptions identityServerOptions){ identityServerOptions.UserInteraction.LoginUrl = "/Controller/Action";}
2、直接在Startup中ConfigureServices中配置
services.AddIdentityServer(options => { options.UserInteraction = new IdentityServer4.Configuration.UserInteractionOptions { LoginUrl = "/Account/Login",//登录地址 LogoutUrl = "/Account/Logout",//退出地址 ConsentUrl = "/Account/Consent",//允许授权同意页面地址 ErrorUrl = "/Account/Error", //错误页面地址 LoginReturnUrlParameter = "ReturnUrl",//设置传递给登录页面的返回URL参数的名称。默认为returnUrl LogoutIdParameter = "logoutId", //设置传递给注销页面的注销消息ID参数的名称。缺省为logoutId ConsentReturnUrlParameter = "ReturnUrl", //设置传递给同意页面的返回URL参数的名称。默认为returnUrl ErrorIdParameter = "errorId", //设置传递给错误页面的错误消息ID参数的名称。缺省为errorId CustomRedirectReturnUrlParameter = "ReturnUrl", //设置从授权端点传递给自定义重定向的返回URL参数的名称。默认为returnUrl CookieMessageThreshold = 5 //由于浏览器对Cookie的大小有限制,设置Cookies数量的限制,有效的保证了浏览器打开多个选项卡,一旦超出了Cookies限制就会清除以前的Cookies值 }; }) .AddDeveloperSigningCredential() .AddInMemoryIdentityResources(MemoryClients.GetIdentityResources()) .AddInMemoryApiResources(MemoryClients.GetApiResources()) .AddInMemoryClients(MemoryClients.GetClients());