zoukankan      html  css  js  c++  java
  • Identityserver4在.netCore3上的错误记录日志

    一、报下面的错误

    {StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Transfer-Encoding: chunked
      Date: Tue, 15 Sep 2020 09:35:01 GMT
      Server: Microsoft-IIS/10.0
      WWW-Authenticate: Bearer
      X-Powered-By: ASP.NET
    }}

    解决方法:

    1:漏掉了下面这一行

            public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime)
            {
                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
    
                app.UseRouting();
                app.UseAuthentication();
                //添加了授权中间件,以确保匿名客户端无法访问我们的API端点。
                app.UseAuthorization();
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
                //程序停止调用函数
                appLifetime.ApplicationStopped.Register(() => { AutofacContainer.Dispose(); });
            }

    2、这两行顺序弄反了

            public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime)
            {
                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
    
                app.UseRouting();
                app.UseAuthorization();//这顺序是错误的
                app.UseAuthentication();//这顺序是错误的
                //添加了授权中间件,以确保匿名客户端无法访问我们的API端点。
    
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
                //程序停止调用函数
                appLifetime.ApplicationStopped.Register(() => { AutofacContainer.Dispose(); });
            }

    二、报下面的错误

    {StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Transfer-Encoding: chunked
      Date: Tue, 15 Sep 2020 09:40:00 GMT
      Server: Microsoft-IIS/10.0
      X-Powered-By: ASP.NET
      Content-Type: text/plain
    }}

    解决方法如下:

    漏掉了下面这一行

            public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime)
            {
                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
    
                app.UseRouting();
                app.UseAuthentication();
                //添加了授权中间件,以确保匿名客户端无法访问我们的API端点。
                app.UseAuthorization();
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
                //程序停止调用函数
                appLifetime.ApplicationStopped.Register(() => { AutofacContainer.Dispose(); });
            }
  • 相关阅读:
    Python File readline() 方法
    Python File read() 方法
    Python File next() 方法
    Python File isatty() 方法
    POJ 3281 Dining(最大流板子)
    poj 3436 ACM Computer Factory 最大流+记录路径
    HDU2732 Leapin' Lizards 最大流
    线段覆盖、区间选点、区间覆盖贪心讲解
    顺序表完成教师职称管理系统
    c++派生类中构造函数和析构函数执行顺序、判断对象类型、抽象类、虚函数
  • 原文地址:https://www.cnblogs.com/wjx-blog/p/13674359.html
Copyright © 2011-2022 走看看