12
12
using Microsoft . AspNetCore . Http ;
13
13
using Microsoft . Net . Http . Headers ;
14
14
using StartupProject_Asp . NetCore_PostGRE . Services . EmailService ;
15
+ using WebMarkupMin . AspNetCore3 ;
15
16
16
17
namespace StartupProject_Asp . NetCore_PostGRE
17
18
{
@@ -78,11 +79,28 @@ public void ConfigureServices(IServiceCollection services)
78
79
. AddEntityFrameworkStores < ApplicationDbContext > ( )
79
80
. AddDefaultTokenProviders ( )
80
81
. AddDefaultUI ( ) ;
81
-
82
+
83
+ services . Configure < SecurityStampValidatorOptions > ( options =>
84
+ {
85
+ options . ValidationInterval = TimeSpan . FromSeconds ( 1 ) ; //Update Auth every second after role updated
86
+ } ) ;
82
87
83
88
services . AddControllersWithViews ( ) ;
84
89
services . AddRazorPages ( ) ;
85
-
90
+ services . AddWebMarkupMin (
91
+ options =>
92
+ {
93
+ options . AllowMinificationInDevelopmentEnvironment = false ;
94
+ options . AllowCompressionInDevelopmentEnvironment = false ;
95
+ } )
96
+ . AddHtmlMinification (
97
+ options =>
98
+ {
99
+ options . MinificationSettings . RemoveRedundantAttributes = true ;
100
+ options . MinificationSettings . RemoveHttpProtocolFromAttributes = true ;
101
+ options . MinificationSettings . RemoveHttpsProtocolFromAttributes = true ;
102
+ } )
103
+ . AddHttpCompression ( ) ;
86
104
services . AddHsts ( options =>
87
105
{
88
106
options . Preload = true ;
@@ -92,11 +110,11 @@ public void ConfigureServices(IServiceCollection services)
92
110
//options.ExcludedHosts.Add("www.example.com");
93
111
} ) ;
94
112
95
- // services.AddHttpsRedirection(options =>
96
- // {
97
- // options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect;
98
- // options.HttpsPort = 5001;
99
- // });
113
+ services . AddHttpsRedirection ( options =>
114
+ {
115
+ options . RedirectStatusCode = StatusCodes . Status307TemporaryRedirect ;
116
+ options . HttpsPort = 5001 ;
117
+ } ) ;
100
118
}
101
119
102
120
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -124,21 +142,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) //IWebHo
124
142
//OnlyIfCached = false,
125
143
MaxAge = TimeSpan . FromDays ( 365 ) // 1 year
126
144
}
127
- }
128
- /*
129
- new StaticFileOptions()
130
- {
131
- //Configure Caching of static files
132
- OnPrepareResponse = context =>
133
- {
134
- context.Context.Response.Headers.Add("Cache-Control", "max-age=31622400, public, no-transform");
135
- //context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store");
136
- //context.Context.Response.Headers.Add("Expires", "-1");
137
- }
138
- }
139
- */
140
- ) ;
141
-
145
+ } ) ;
146
+ app . UseWebMarkupMin ( ) ;
142
147
app . UseRouting ( ) ;
143
148
144
149
app . UseAuthentication ( ) ;
0 commit comments