1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Threading . Tasks ;
5- using Microsoft . AspNetCore . Builder ;
6- using Microsoft . AspNetCore . Hosting ;
7- using Microsoft . AspNetCore . HttpsPolicy ;
8- using Microsoft . Extensions . Configuration ;
9- using Microsoft . Extensions . DependencyInjection ;
10- using Microsoft . Extensions . Hosting ;
111using Serilog ;
122
13- namespace Sample
3+ namespace Sample ;
4+
5+ public class Startup
146{
15- public class Startup
7+ public Startup ( IConfiguration configuration )
168 {
17- public Startup ( IConfiguration configuration )
18- {
19- Configuration = configuration ;
20- }
9+ Configuration = configuration ;
10+ }
2111
22- public IConfiguration Configuration { get ; }
12+ public IConfiguration Configuration { get ; }
13+
14+ // This method gets called by the runtime. Use this method to add services to the container.
15+ public void ConfigureServices ( IServiceCollection services )
16+ {
17+ services . AddControllersWithViews ( ) ;
18+ }
2319
24- // This method gets called by the runtime. Use this method to add services to the container.
25- public void ConfigureServices ( IServiceCollection services )
20+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
21+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
22+ {
23+ if ( env . IsDevelopment ( ) )
2624 {
27- services . AddControllersWithViews ( ) ;
25+ app . UseDeveloperExceptionPage ( ) ;
2826 }
29-
30- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
31- public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
27+ else
3228 {
33- if ( env . IsDevelopment ( ) )
34- {
35- app . UseDeveloperExceptionPage ( ) ;
36- }
37- else
38- {
39- app . UseExceptionHandler ( "/Home/Error" ) ;
40- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
41- app . UseHsts ( ) ;
42- }
29+ app . UseExceptionHandler ( "/Home/Error" ) ;
30+ // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
31+ app . UseHsts ( ) ;
32+ }
4333
44- app . UseHttpsRedirection ( ) ;
45- app . UseStaticFiles ( ) ;
46-
47- // Write streamlined request completion events, instead of the more verbose ones from the framework.
48- // To use the default framework request logging instead, remove this line and set the "Microsoft"
49- // level in appsettings.json to "Information".
50- app . UseSerilogRequestLogging ( ) ;
34+ app . UseHttpsRedirection ( ) ;
35+ app . UseStaticFiles ( ) ;
5136
52- app . UseRouting ( ) ;
37+ // Write streamlined request completion events, instead of the more verbose ones from the framework.
38+ // To use the default framework request logging instead, remove this line and set the "Microsoft"
39+ // level in appsettings.json to "Information".
40+ app . UseSerilogRequestLogging ( ) ;
5341
54- app . UseAuthorization ( ) ;
42+ app . UseRouting ( ) ;
5543
56- app . UseEndpoints ( endpoints =>
57- {
58- endpoints . MapControllerRoute (
59- name : "default" ,
60- pattern : "{controller=Home}/{action=Index}/{id?}" ) ;
61- } ) ;
62- }
44+ app . UseAuthorization ( ) ;
45+
46+ app . UseEndpoints ( endpoints =>
47+ {
48+ endpoints . MapControllerRoute (
49+ name : "default" ,
50+ pattern : "{controller=Home}/{action=Index}/{id?}" ) ;
51+ } ) ;
6352 }
6453}
0 commit comments