// 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(); } var swaggerOptions = new SwaggerOpt(); Configuration.GetSection(nameof(SwaggerOpt)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UIEndpoint, swaggerOptions.Description); }); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } var swaggerOpt = new SwaggerOpt(); Configuration.GetSection(nameof(SwaggerOpt)).Bind(swaggerOpt); app.UseSwagger(opt => { opt.RouteTemplate = swaggerOpt.JsonRoute; }); app.UseSwaggerUI(opt => { opt.SwaggerEndpoint(swaggerOpt.UIEndPoint, swaggerOpt.Description); }); app.UseHttpsRedirection(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseCors(MyAllowSpecificOrigins); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); loggerFactory.AddSerilog(); // <-- enable Serilog Middleware var swaggerOpt = new SwaggerOpt(); Configuration.GetSection(nameof(SwaggerOpt)).Bind(swaggerOpt); app.UseSwagger(opt => { opt.RouteTemplate = swaggerOpt.JsonRoute; }); app.UseSwaggerUI(opt => { opt.SwaggerEndpoint(swaggerOpt.UIEndPoint, swaggerOpt.Description); }); app.UseHttpsRedirection(); app.UseMvc(); }
// 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.UseRouting(); app.UseCors(x => x .AllowAnyMethod() .AllowAnyHeader() .SetIsOriginAllowed(origin => true) // allow any origin .AllowCredentials()); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); var swaggerOpt = new SwaggerOpt(); Configuration.GetSection(nameof(SwaggerOpt)).Bind(swaggerOpt); app.UseSwagger(opt => { opt.RouteTemplate = swaggerOpt.JsonRoute; }); app.UseSwaggerUI(opt => { opt.SwaggerEndpoint(swaggerOpt.UIEndPoint, swaggerOpt.Description); }); app.UseHttpsRedirection(); }