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 ;
11
1
using Serilog ;
12
2
13
- namespace Sample
3
+ namespace Sample ;
4
+
5
+ public class Startup
14
6
{
15
- public class Startup
7
+ public Startup ( IConfiguration configuration )
16
8
{
17
- public Startup ( IConfiguration configuration )
18
- {
19
- Configuration = configuration ;
20
- }
9
+ Configuration = configuration ;
10
+ }
21
11
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
+ }
23
19
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 ( ) )
26
24
{
27
- services . AddControllersWithViews ( ) ;
25
+ app . UseDeveloperExceptionPage ( ) ;
28
26
}
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
32
28
{
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
+ }
43
33
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 ( ) ;
51
36
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 ( ) ;
53
41
54
- app . UseAuthorization ( ) ;
42
+ app . UseRouting ( ) ;
55
43
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
+ } ) ;
63
52
}
64
53
}
0 commit comments