net core 3.1使用identityServer登录时signin-oidc报Correlation failed的解决方法
2024-10-21 06:34:34
此问题全网找了很久,也困扰了我很久,始终没有找到解决方法。今天结合网上其他问题的帖子,自己研究的半天,终于找到了这个解决方法,经亲自测试可行。欢迎大牛指导指正。
有时客户收藏的系统地址是认证端的,然后登录之后会转向https://***:101/signin-oidc 报以下错误
An unhandled exception occurred while processing the request.
Exception: Correlation failed.
Unknown location
Exception: An error was encountered while handling the remote login.
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler<TOptions>.HandleRequestAsync()
解决的原理就是,当远程认证错误时,转向最开始的系统首页。
解决方法
1 services.AddAuthentication(options =>
2 {
3 options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
4 options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
5 })
6 .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
7 .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options =>
8 {
9 options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
10 ………………省略内容………………
11 //------------------此处开始为处理此问题-------------------
12 options.Events=new OpenIdConnectEvents()
13 { //修复登录成功之后转向signin-oidc并报错的问题
14 OnRemoteFailure = ctx =>
15 {
16 ctx.Response.Redirect($"{ctx.Request.Scheme}://{ctx.Request.Host}");
17 ctx.Response.Body.WriteAsync(null);
18 return Task.CompletedTask;
19 }
20 };
21 //---------------------处理此问题结束--------------------------------------
22 });
最新文章
- Python全栈开发day9
- View (二) 自定义属性 自定义属性的格式详解
- (1) css的核心基础
- ARM处理器全解析:A8/A9/A15都是什么?
- [lua]协同式多任务,统筹运用
- javascript写的ajax请求
- 类型转换操作符static_cast、const_cast、dynamic_cast、reinterpret_cast
- 理解JavaScript 的原型属性
- ECLIPSE中反编译插件JAD的配置安装,轻松查看JAVA源代码
- Angularjs通过$http与服务器通信
- ubuntu 解压 windows 生成的 zip 文件乱码问题
- 关于操作HDFS的一个问题
- npm由来和作用
- dbForge Studio for MySQL 中文乱码问题
- [转]Docker基础-使用Dockerfile创建镜像
- Create a toolwindow for the VBA editor with .NET(C#).
- [ZJOI2015]地震后的幻想乡(期望+dp)
- Beta阶段冲刺集合贴
- vue 绑定属性 绑定Class 绑定style
- 一分钟理清Vue-cli 代码构建步骤。