C# 是否需要对具有ASP.NET Core 3.0的IActionContextAccessor进行任何额外配置?
因此,我正在尝试将我的ASP.NET核心项目迁移到3.0,并且正在进行一些突破性的更改。我正在尝试使用OpenID Connect和AWS Cognito对web应用程序的用户进行身份验证。在我的2.2项目中工作得很好,但在3.0中不再工作(预览9) 这是我收到的错误:C# 是否需要对具有ASP.NET Core 3.0的IActionContextAccessor进行任何额外配置?,c#,asp.net,openid-connect,C#,Asp.net,Openid Connect,因此,我正在尝试将我的ASP.NET核心项目迁移到3.0,并且正在进行一些突破性的更改。我正在尝试使用OpenID Connect和AWS Cognito对web应用程序的用户进行身份验证。在我的2.2项目中工作得很好,但在3.0中不再工作(预览9) 这是我收到的错误: An unhandled exception has occurred while executing the request. System.ArgumentNullException: context (Parameter
An unhandled exception has occurred while executing the request.
System.ArgumentNullException: context (Parameter 'Value cannot be null or empty.')
at Microsoft.AspNetCore.Mvc.Routing.UrlHelperFactory.GetUrlHelper(ActionContext context)
在尝试设置时,我的IActionContextAccessor
现在似乎是null
IActionContextAccessor
被注入到AuthenticationBuilder
函数中
我不确定可能是什么问题
在配置函数的my startup.cs中,我有以下内容:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UsePathBase("/");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/error/500/");
}
app.UseStatusCodePagesWithRedirects("/error/{0}/");
app.UseAuthentication();
if (env.IsProduction())
{
app.Use((context, next) =>
{
// https://github.com/aspnet/Security/issues/757
context.Request.Scheme = "https";
return next();
});
}
app.UseStaticFiles();
app.UseRouting();
//app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Endpoints}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
}
我的.csproj
中也包含了这一点:
有什么奇怪的事情我现在错过了吗?我也有同样的问题。你找到答案了吗?嗨,@MikeBrunner我回顾了我的工作解决方案(我已经将nuget软件包更新到了3.1.2版。但是,我发现它很有用。我知道我需要确保
app.UseAuthentication()
在app.UseAuthorization()之前完成了