当前位置: 首页> 汽车> 维修 > 免费网站建设垂询186 6159 6345_真实的网站建设_seo首页网站_培训机构不退钱最怕什么举报

免费网站建设垂询186 6159 6345_真实的网站建设_seo首页网站_培训机构不退钱最怕什么举报

时间:2025/7/9 21:16:21来源:https://blog.csdn.net/bjhtgy/article/details/143267968 浏览次数: 0次
免费网站建设垂询186 6159 6345_真实的网站建设_seo首页网站_培训机构不退钱最怕什么举报

 public class Startup

    {

        public Startup(IConfiguration configuration)

        {

            Configuration = configuration;

        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.

        public void ConfigureServices(IServiceCollection services)

        {

            services.Configure<Configure>(Configuration.GetSection("Token"));

            services.AddControllers();

            var serverVersion = new MySqlServerVersion(new Version(8, 0, 25));

            services.AddDbContext<DBServiceContext>(options =>

            {

                options.UseMySql(Configuration.GetConnectionString("DbConnection"), serverVersion);

            });

            services.AddSwaggerGen(c =>

            {

                c.SwaggerDoc("v1", new OpenApiInfo { Title = "一板一码模拟后台接口", Version = "v1" });

                //c.IncludeXmlComments(string.Format("{0}/RunnerService.xml", AppDomain.CurrentDomain.BaseDirectory));

            });


 

            services.AddAuthentication(options =>

            {

                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;

                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

            }).AddJwtBearer(x =>

            {

                x.RequireHttpsMetadata = false;

                x.SaveToken = true;

                x.TokenValidationParameters = new TokenValidationParameters

                {

                    ValidateIssuerSigningKey = true,//是否调用对签名securityToken的SecurityKey进行验证

                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration.GetSection("Token").GetSection("Secret").Value.ToString())),//签名秘钥

                    ValidateIssuer = true,//是否验证颁发者

                    ValidIssuer = Configuration.GetSection("Token").GetSection("Issuer").Value.ToString(),

                    ValidateAudience = true, //是否验证接收者

                    ValidAudience = Configuration.GetSection("Token").GetSection("Audience").Value.ToString(),//接收者

                    ValidateLifetime = true,//是否验证失效时间

                };

            });


 

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

        {

            if (env.IsDevelopment())

            {

                app.UseDeveloperExceptionPage();

                //app.UseSwagger();

                //app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "RunnerService v1"));

                //app.UseSwaggerUI(c =>

                //{

                //    c.SwaggerEndpoint("/swagger/v1/swagger.json", "RunnerService v1");

                //    c.RoutePrefix = string.Empty;//设置根节点访问  

                //});

            }

           

            app.UseSwagger();

            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Service v1"));

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>

            {

                endpoints.MapControllers();

            });

        }

    }

配置数据

{

  "Logging": {

    "LogLevel": {

      "Default": "Information",

      "Microsoft": "Warning",

      "Microsoft.Hosting.Lifetime": "Information"

    }

  },

  "AllowedHosts": "*",

  "ConnectionStrings": {

    "DbConnection": "server=ip地址;port=3306;database=数据库名称;user=root;password=123456;"

  },

  "Token": {

    "Issuer": "test",

    "Audience": "test",

    "Secret": "123456",

    "AccessExpiration": "30"

  }

}

关键字:免费网站建设垂询186 6159 6345_真实的网站建设_seo首页网站_培训机构不退钱最怕什么举报

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: