1
- using System ;
2
- using System . Collections . Generic ;
3
- using System . Linq ;
4
- using System . Threading . Tasks ;
5
- using Microsoft . AspNetCore . Builder ;
1
+ using Microsoft . AspNetCore . Builder ;
6
2
using Microsoft . AspNetCore . Hosting ;
7
3
using Microsoft . AspNetCore . Http ;
8
- using Microsoft . AspNetCore . HttpsPolicy ;
9
- using Microsoft . AspNetCore . Mvc ;
10
4
using Microsoft . Extensions . Configuration ;
11
5
using Microsoft . Extensions . DependencyInjection ;
6
+ using Microsoft . Extensions . Hosting ;
12
7
13
8
namespace pipelines_dotnet_core
14
9
{
@@ -24,41 +19,43 @@ public Startup(IConfiguration configuration)
24
19
// This method gets called by the runtime. Use this method to add services to the container.
25
20
public void ConfigureServices ( IServiceCollection services )
26
21
{
27
- services . Configure < CookiePolicyOptions > ( options =>
28
- {
22
+ _ = services . Configure < CookiePolicyOptions > ( options =>
23
+ {
29
24
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
30
25
options . CheckConsentNeeded = context => true ;
31
- options . MinimumSameSitePolicy = SameSiteMode . None ;
32
- } ) ;
26
+ options . MinimumSameSitePolicy = SameSiteMode . None ;
27
+ } ) ;
33
28
34
29
35
- services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_2 ) ;
30
+ services . AddRazorPages ( ) ;
36
31
}
37
32
38
33
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
39
- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
34
+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
40
35
{
41
- if ( env . IsDevelopment ( ) )
42
- {
43
- app . UseDeveloperExceptionPage ( ) ;
44
- }
45
- else
36
+ if ( ! env . IsDevelopment ( ) )
46
37
{
47
38
app . UseExceptionHandler ( "/Home/Error" ) ;
48
39
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
49
40
app . UseHsts ( ) ;
50
41
}
42
+ else
43
+ {
44
+ app . UseDeveloperExceptionPage ( ) ;
45
+ }
51
46
52
47
app . UseHttpsRedirection ( ) ;
53
48
app . UseStaticFiles ( ) ;
54
49
app . UseCookiePolicy ( ) ;
55
50
56
- app . UseMvc ( routes =>
51
+ app . UseRouting ( ) ;
52
+
53
+ app . UseEndpoints ( endpoints =>
57
54
{
58
- routes . MapRoute (
55
+ endpoints . MapControllerRoute (
59
56
name : "default" ,
60
- template : "{controller=Home}/{action=Index}/{id?}" ) ;
57
+ pattern : "{controller=Home}/{action=Index}/{id?}" ) ;
61
58
} ) ;
62
59
}
63
60
}
64
- }
61
+ }
0 commit comments