Skip to content

Commit cd8e974

Browse files
Update filter.md (dotnet#17036)
* Update filter.md * Update aspnetcore/razor-pages/filter.md Co-Authored-By: Artak <34246760+mkArtakMSFT@users.noreply.github.com> Co-authored-by: Artak <34246760+mkArtakMSFT@users.noreply.github.com>
1 parent 307795f commit cd8e974

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

aspnetcore/razor-pages/filter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: Rick-Anderson
44
description: Learn how to create filter methods for Razor Pages in ASP.NET Core.
55
monikerRange: '>= aspnetcore-2.1'
66
ms.author: riande
7-
ms.date: 12/28/2019
7+
ms.date: 2/18/2020
88
uid: razor-pages/filter
99
---
1010
# Filter methods for Razor Pages in ASP.NET Core
@@ -24,7 +24,7 @@ Razor Page filters:
2424
* Cannot be applied to specific page handler methods.
2525
* Can have constructor dependencies populated by [Dependency Injection](xref:fundamentals/dependency-injection) (DI). For more information, see [ServiceFilterAttribute](/aspnet/core/mvc/controllers/filters#servicefilterattribute) and [TypeFilterAttribute](/aspnet/core/mvc/controllers/filters#typefilterattribute).
2626

27-
Code can be run before a handler method executes using the page constructor or middleware, but only Razor Page filters have access to <xref:Microsoft.AspNetCore.Mvc.RazorPages.PageModel.HttpContext>. Filters have a <xref:Microsoft.AspNetCore.Mvc.Filters.FilterContext> derived parameter, which provides access to `HttpContext`. For example, the [Implement a filter attribute](#ifa) sample adds a header to the response, something that can't be done with constructors or middleware.
27+
While page constructors and middleware enable executing custom code before a handler method executes, only Razor Page filters enable access to <xref:Microsoft.AspNetCore.Mvc.RazorPages.PageModel.HttpContext> and the page. Middleware has access to the `HttpContext`, but not to the "page context". Filters have a <xref:Microsoft.AspNetCore.Mvc.Filters.FilterContext> derived parameter, which provides access to `HttpContext`. For example, the [Implement a filter attribute](#ifa) sample adds a header to the response, something that can't be done with constructors or middleware.
2828

2929
[View or download sample code](https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/razor-pages/filter/3.1sample) ([how to download](xref:index#how-to-download-a-sample))
3030

0 commit comments

Comments
 (0)