File tree Expand file tree Collapse file tree 8 files changed +52
-1
lines changed
WebSites/TagHelpersWebSite Expand file tree Collapse file tree 8 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ protected async Task ExecuteAsync(
233
233
234
234
OnExecuting ( viewContext ) ;
235
235
236
- using ( var writer = WriterFactory . CreateWriter ( response . Body , resolvedContentTypeEncoding ) )
236
+ await using ( var writer = WriterFactory . CreateWriter ( response . Body , resolvedContentTypeEncoding ) )
237
237
{
238
238
var view = viewContext . View ;
239
239
Original file line number Diff line number Diff line change @@ -64,6 +64,16 @@ public async Task CanRenderViewsWithTagHelpers(string action)
64
64
#endif
65
65
}
66
66
67
+ [ Fact ]
68
+ public async Task GivesCorrectCallstackForSyncronousCalls ( )
69
+ {
70
+ // Arrange, Act and Assert
71
+ var exception = await Assert . ThrowsAsync < HttpRequestException > ( async ( ) => await Client . GetAsync ( "http://localhost/Home/MyHtml" ) ) ;
72
+
73
+ // Assert
74
+ Assert . Equal ( "Should be visible" , exception . InnerException . InnerException . Message ) ;
75
+ }
76
+
67
77
[ Fact ]
68
78
public async Task CanRenderViewsWithTagHelpersAndUnboundDynamicAttributes_Encoded ( )
69
79
{
Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ public IActionResult Help()
35
35
return View ( ) ;
36
36
}
37
37
38
+ public IActionResult MyHtml ( )
39
+ {
40
+ return View ( ) ;
41
+ }
42
+
38
43
public IActionResult ViewComponentTagHelpers ( )
39
44
{
40
45
return View ( ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
+
4
+ using System . IO ;
5
+ using System . Text . Encodings . Web ;
6
+ using Microsoft . AspNetCore . Html ;
7
+ using Microsoft . AspNetCore . Mvc . Rendering ;
8
+
9
+ namespace TagHelpersWebSite
10
+ {
11
+ public class MyHtmlContent : IHtmlContent
12
+ {
13
+ private IHtmlHelper Html { get ; }
14
+
15
+ public MyHtmlContent ( IHtmlHelper html )
16
+ {
17
+ Html = html ;
18
+ }
19
+
20
+ public void WriteTo ( TextWriter writer , HtmlEncoder encoder )
21
+ {
22
+ #pragma warning disable MVC1000 // Use of IHtmlHelper.{0} should be avoided.
23
+ Html . Partial ( "_Test" ) . WriteTo ( writer , encoder ) ;
24
+ #pragma warning restore MVC1000 // Use of IHtmlHelper.{0} should be avoided.
25
+ }
26
+ }
27
+ }
Original file line number Diff line number Diff line change 3
3
4
4
using System . IO ;
5
5
using Microsoft . AspNetCore . Builder ;
6
+ using Microsoft . AspNetCore . Diagnostics ;
6
7
using Microsoft . AspNetCore . Hosting ;
7
8
using Microsoft . AspNetCore . Mvc ;
8
9
using Microsoft . Extensions . DependencyInjection ;
@@ -20,6 +21,7 @@ public void ConfigureServices(IServiceCollection services)
20
21
21
22
public void Configure ( IApplicationBuilder app )
22
23
{
24
+ app . UseDeveloperExceptionPage ( ) ;
23
25
app . UseRouting ( ) ;
24
26
app . UseStaticFiles ( ) ;
25
27
app . UseEndpoints ( endpoints =>
Original file line number Diff line number Diff line change 12
12
13
13
<ItemGroup >
14
14
<Reference Include =" Microsoft.AspNetCore.Mvc" />
15
+ <Reference Include =" Microsoft.AspNetCore.Diagnostics" />
15
16
<Reference Include =" Microsoft.AspNetCore.Server.IISIntegration" />
16
17
<Reference Include =" Microsoft.AspNetCore.Server.Kestrel" />
17
18
<Reference Include =" Microsoft.AspNetCore.StaticFiles" />
19
+ <Reference Include =" Microsoft.Extensions.Logging.Console" />
20
+ <Reference Include =" Microsoft.Extensions.Logging.Debug" />
18
21
</ItemGroup >
19
22
</Project >
Original file line number Diff line number Diff line change
1
+ @( new TagHelpersWebSite .MyHtmlContent (Html ))
Original file line number Diff line number Diff line change
1
+ @{
2
+ throw new Exception (" Should be visible" );
3
+ }
You can’t perform that action at this time.
0 commit comments