【问题标题】:ASP.Net Core `UseAuthorization` not recognizedASP.Net Core `UseAuthorization` 无法识别
【发布时间】:2020-10-15 15:42:39
【问题描述】:

我的Configure 方法中有以下代码发出警告:

上面写着:

对 UseAuthorization 的调用应该出现在 app.UseRouting() 和 app.UseEndpoints(..) 之间,以便正确评估授权。

显然是在这些电话之间。我会认为这是错误的并继续前进,但是当我调用我的服务操作时,我得到了这个错误:

代码不会运行,因为它认为我的UseAuthorization 不在UseRoutingUseEndpoints 之间。

我被难住了!不知道我需要改变什么才能完成这项工作。任何关于我所缺少的建议将不胜感激。

【问题讨论】:

  • 你有什么版本的asp.net core?

标签: c# asp.net-core .net-core asp.net-core-3.1


【解决方案1】:

事实证明,在Configure 方法中我有这个:

app.UseMiniProfiler()
      .UseStaticFiles()
      .UseRouting()
      .UseEndpoints(endpoints =>
      {
          endpoints.MapDefaultControllerRoute();
      });

我忽略了它,因为我认为这是UseMiniProfiler 的所有配置,但它实际上是链接app 以连续调用UseRoutingUseEndpoints

删除这些调用修复了它!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-09
    • 1970-01-01
    • 2019-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多