@@ -49,10 +49,6 @@ public void ConfigureServices(IServiceCollection services)
4949 services . AddScoped < InteractiveServerService > ( ) ;
5050 services . AddScoped < InteractiveAutoService > ( ) ;
5151
52-
53-
54-
55-
5652 services . AddHttpContextAccessor ( ) ;
5753 services . AddSingleton < AsyncOperationService > ( ) ;
5854 services . AddCascadingAuthenticationState ( ) ;
@@ -77,57 +73,67 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7773
7874 app . Map ( "/subdir" , app =>
7975 {
80- WebAssemblyTestHelper . ServeCoopHeadersIfWebAssemblyThreadingEnabled ( app ) ;
81-
82- if ( ! env . IsDevelopment ( ) )
76+ app . Map ( "/reexecution" , reexecutionApp =>
8377 {
84- app . UseExceptionHandler ( "/Error" , createScopeForErrors : true ) ;
85- }
78+ reexecutionApp . UseStatusCodePagesWithReExecute ( "/not-found-reexecute" , true ) ;
79+ } ) ;
8680
87- app . UseRouting ( ) ;
88- UseFakeAuthState ( app ) ;
89- app . UseAntiforgery ( ) ;
81+ ConfigureSubdirPipeline ( app , env ) ;
82+ } ) ;
83+ }
84+
85+ protected virtual void ConfigureSubdirPipeline ( IApplicationBuilder app , IWebHostEnvironment env )
86+ {
87+ WebAssemblyTestHelper . ServeCoopHeadersIfWebAssemblyThreadingEnabled ( app ) ;
9088
91- app . Use ( ( ctx , nxt ) =>
89+ if ( ! env . IsDevelopment ( ) )
90+ {
91+ app . UseExceptionHandler ( "/Error" , createScopeForErrors : true ) ;
92+ }
93+
94+ app . UseRouting ( ) ;
95+ UseFakeAuthState ( app ) ;
96+ app . UseAntiforgery ( ) ;
97+
98+ app . Use ( ( ctx , nxt ) =>
99+ {
100+ if ( ctx . Request . Query . ContainsKey ( "add-csp" ) )
92101 {
93- if ( ctx . Request . Query . ContainsKey ( "add-csp" ) )
94- {
95- ctx . Response . Headers . Add ( "Content-Security-Policy" , "script-src 'self' 'unsafe-inline'" ) ;
96- }
97- return nxt ( ) ;
98- } ) ;
102+ ctx . Response . Headers . Add ( "Content-Security-Policy" , "script-src 'self' 'unsafe-inline'" ) ;
103+ }
104+ return nxt ( ) ;
105+ } ) ;
99106
100- _ = app . UseEndpoints ( endpoints =>
107+ _ = app . UseEndpoints ( endpoints =>
108+ {
109+ var contentRootStaticAssetsPath = Path . Combine ( env . ContentRootPath , "Components.TestServer.staticwebassets.endpoints.json" ) ;
110+ if ( File . Exists ( contentRootStaticAssetsPath ) )
101111 {
102- var contentRootStaticAssetsPath = Path . Combine ( env . ContentRootPath , "Components.TestServer.staticwebassets.endpoints.json" ) ;
103- if ( File . Exists ( contentRootStaticAssetsPath ) )
104- {
105- endpoints . MapStaticAssets ( contentRootStaticAssetsPath ) ;
106- }
107- else
108- {
109- endpoints . MapStaticAssets ( ) ;
110- }
112+ endpoints . MapStaticAssets ( contentRootStaticAssetsPath ) ;
113+ }
114+ else
115+ {
116+ endpoints . MapStaticAssets ( ) ;
117+ }
111118
112- _ = endpoints . MapRazorComponents < TRootComponent > ( )
113- . AddAdditionalAssemblies ( Assembly . Load ( "Components.WasmMinimal" ) )
114- . AddInteractiveServerRenderMode ( options =>
115- {
116- var config = app . ApplicationServices . GetRequiredService < WebSocketCompressionConfiguration > ( ) ;
117- options . DisableWebSocketCompression = config . IsCompressionDisabled ;
119+ _ = endpoints . MapRazorComponents < TRootComponent > ( )
120+ . AddAdditionalAssemblies ( Assembly . Load ( "Components.WasmMinimal" ) )
121+ . AddInteractiveServerRenderMode ( options =>
122+ {
123+ var config = app . ApplicationServices . GetRequiredService < WebSocketCompressionConfiguration > ( ) ;
124+ options . DisableWebSocketCompression = config . IsCompressionDisabled ;
118125
119- options . ContentSecurityFrameAncestorsPolicy = config . CspPolicy ;
126+ options . ContentSecurityFrameAncestorsPolicy = config . CspPolicy ;
120127
121- options . ConfigureWebSocketAcceptContext = config . ConfigureWebSocketAcceptContext ;
122- } )
123- . AddInteractiveWebAssemblyRenderMode ( options => options . PathPrefix = "/WasmMinimal" ) ;
128+ options . ConfigureWebSocketAcceptContext = config . ConfigureWebSocketAcceptContext ;
129+ } )
130+ . AddInteractiveWebAssemblyRenderMode ( options => options . PathPrefix = "/WasmMinimal" ) ;
124131
125- NotEnabledStreamingRenderingComponent . MapEndpoints ( endpoints ) ;
126- StreamingRenderingForm . MapEndpoints ( endpoints ) ;
127- InteractiveStreamingRenderingComponent . MapEndpoints ( endpoints ) ;
132+ NotEnabledStreamingRenderingComponent . MapEndpoints ( endpoints ) ;
133+ StreamingRenderingForm . MapEndpoints ( endpoints ) ;
134+ InteractiveStreamingRenderingComponent . MapEndpoints ( endpoints ) ;
128135
129- MapEnhancedNavigationEndpoints ( endpoints ) ;
130- } ) ;
136+ MapEnhancedNavigationEndpoints ( endpoints ) ;
131137 } ) ;
132138 }
133139
0 commit comments