Skip to content

Commit 75bf3a1

Browse files
Moniker prep (#29559)
* Moniker prep * Moniker prep * Moniker prep
1 parent 81707e3 commit 75bf3a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1950
-647
lines changed

aspnetcore/mvc/controllers/filters.md

Lines changed: 33 additions & 647 deletions
Large diffs are not rendered by default.

aspnetcore/mvc/controllers/filters/includes/filters7.md

Lines changed: 1148 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FiltersSample.Filters;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.AspNetCore.Mvc.Filters;
4+
5+
namespace FiltersSample.Controllers;
6+
7+
// <snippet_Class>
8+
[SampleActionFilter]
9+
public class ControllerFiltersController : Controller
10+
{
11+
public override void OnActionExecuting(ActionExecutingContext context)
12+
{
13+
Console.WriteLine(
14+
$"- {nameof(ControllerFiltersController)}.{nameof(OnActionExecuting)}");
15+
16+
base.OnActionExecuting(context);
17+
}
18+
19+
public override void OnActionExecuted(ActionExecutedContext context)
20+
{
21+
Console.WriteLine(
22+
$"- {nameof(ControllerFiltersController)}.{nameof(OnActionExecuted)}");
23+
24+
base.OnActionExecuted(context);
25+
}
26+
27+
public IActionResult Index()
28+
{
29+
Console.WriteLine(
30+
$"- {nameof(ControllerFiltersController)}.{nameof(Index)}");
31+
32+
return Content("Check the Console.");
33+
}
34+
}
35+
// </snippet_Class>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using FiltersSample.Filters;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace FiltersSample.Controllers;
5+
6+
// <snippet_Class>
7+
[TypeFilter(typeof(SampleExceptionFilter))]
8+
public class ExceptionController : Controller
9+
{
10+
public IActionResult Index() =>
11+
Content($"- {nameof(ExceptionController)}.{nameof(Index)}");
12+
}
13+
// </snippet_Class>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using FiltersSample.Filters;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace FiltersSample.Controllers;
5+
6+
public class FilterDependenciesController : Controller
7+
{
8+
// <snippet_ServiceFilter>
9+
[ServiceFilter(typeof(LoggingResponseHeaderFilterService))]
10+
public IActionResult WithServiceFilter() =>
11+
Content($"- {nameof(FilterDependenciesController)}.{nameof(WithServiceFilter)}");
12+
// </snippet_ServiceFilter>
13+
14+
// <snippet_TypeFilter>
15+
[TypeFilter(typeof(LoggingResponseHeaderFilter),
16+
Arguments = new object[] { "Filter-Header", "Filter Value" })]
17+
public IActionResult WithTypeFilter() =>
18+
Content($"- {nameof(FilterDependenciesController)}.{nameof(WithTypeFilter)}");
19+
// </snippet_TypeFilter>
20+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using FiltersSample.Filters;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace FiltersSample.Controllers;
5+
6+
public class FilterFactoryController : Controller
7+
{
8+
// <snippet_Index>
9+
[ResponseHeaderFilterFactory]
10+
public IActionResult Index() =>
11+
Content($"- {nameof(FilterFactoryController)}.{nameof(Index)}");
12+
// </snippet_Index>
13+
14+
// <snippet_TypeFilterAttribute>
15+
[SampleActionTypeFilter]
16+
public IActionResult WithDirectAttribute() =>
17+
Content($"- {nameof(FilterFactoryController)}.{nameof(WithDirectAttribute)}");
18+
19+
[TypeFilter(typeof(SampleActionTypeFilterAttribute))]
20+
public IActionResult WithTypeFilterAttribute() =>
21+
Content($"- {nameof(FilterFactoryController)}.{nameof(WithTypeFilterAttribute)}");
22+
23+
[ServiceFilter(typeof(SampleActionTypeFilterAttribute))]
24+
public IActionResult WithServiceFilterAttribute() =>
25+
Content($"- {nameof(FilterFactoryController)}.{nameof(WithServiceFilterAttribute)}");
26+
// </snippet_TypeFilterAttribute>
27+
}
28+
// </snippet_Class>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace FiltersSample.Controllers;
4+
5+
// <snippet_Class>
6+
[MiddlewareFilter(typeof(FilterMiddlewarePipeline))]
7+
public class FilterMiddlewareController : Controller
8+
{
9+
public IActionResult Index() =>
10+
Content($"- {nameof(FilterMiddlewareController)}.{nameof(Index)}");
11+
}
12+
// </snippet_Class>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Diagnostics;
2+
using Microsoft.AspNetCore.Mvc;
3+
using FiltersSample.Models;
4+
using FiltersSample.Filters;
5+
6+
namespace FiltersSample.Controllers;
7+
8+
public class HomeController : Controller
9+
{
10+
private readonly ILogger<HomeController> _logger;
11+
12+
public HomeController(ILogger<HomeController> logger)
13+
{
14+
_logger = logger;
15+
}
16+
17+
[ValidateModel]
18+
public IActionResult Index()
19+
{
20+
return View();
21+
}
22+
23+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
24+
public IActionResult Error()
25+
{
26+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
27+
}
28+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Filters.Filters;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace FiltersSample.Controllers;
5+
6+
// <snippet_Class>
7+
// <snippet_ClassIndex>
8+
[ResponseHeader("Filter-Header", "Filter Value")]
9+
public class ResponseHeaderController : ControllerBase
10+
{
11+
public IActionResult Index() =>
12+
Content("Examine the response headers using the F12 developer tools.");
13+
14+
// ...
15+
// </snippet_ClassIndex>
16+
17+
[ResponseHeader("Another-Filter-Header", "Another Filter Value")]
18+
public IActionResult Multiple() =>
19+
Content("Examine the response headers using the F12 developer tools.");
20+
}
21+
// </snippet_Class>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Filters.Filters;
2+
using FiltersSample.Filters;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace FiltersSample.Controllers;
6+
7+
// <snippet_Class>
8+
[ResponseHeader("Filter-Header", "Filter Value")]
9+
public class ShortCircuitingController : Controller
10+
{
11+
[ShortCircuitingResourceFilter]
12+
public IActionResult Index() =>
13+
Content($"- {nameof(ShortCircuitingController)}.{nameof(Index)}");
14+
}
15+
// </snippet_Class>

0 commit comments

Comments
 (0)