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