1. 程式人生 > 實用技巧 >net core 3 報An unhandled exception occurred while processing the request錯誤

net core 3 報An unhandled exception occurred while processing the request錯誤

使用net core 開發時報以下錯誤

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()

看了一下後臺錯誤原因,貌似是cookies沒有儲存上,然後就想到了net core 3 生成的專案模板預設實現了

<<通用資料保護條例>>,所以設定儲存Cookie需要做一些處理。

1.第一種是在Startup的ConfigureServices方法中關閉這個支援.(我使用的此方法解決了以上問題)

services.Configure<CookiePolicyOptions>(option => {
                option.CheckConsentNeeded = context => false;
            });

2.設定儲存的Cookie為重要(未實際試驗)

 this.Response.Cookies.Append("stdio", DateTime.Now.ToString(), new CookieOptions {
                IsEssential = true
            });

參考文章:https://www.cnblogs.com/zzr-stdio/p/10617532.html