-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Razor Pages Filters #5835
Razor Pages Filters #5835
Conversation
|
||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-preview2-30457" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just point this to 2.1.0-preview2-final
(when it's available, which is likely soon)?
aspnetcore/mvc/razor-pages/filter.md
Outdated
|
||
[!code-csharp[Main](filter/sample/PageFilter/StartupSync.cs?name=snippet2&highlight=11)] | ||
|
||
## Implement Razor Page filters by overriding page handlers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overriding filter methods (not handlers)
Yet another thing, that's missing is specifying filters on |
@pranavkm can you send me the code for a filter attribute? |
You could use the same |
@fmaeseele please review. |
@pranavkm Can you take another look. It should be ready. |
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Update="Pages\About.cshtml"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
_value = value; | ||
} | ||
|
||
public override async Task OnResultExecutionAsync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to public override void
OnResultExecuting(ResultExecutingContext context)`? Would be simpler than the async overload.
@@ -0,0 +1,8 @@ | |||
@page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? The folder name \ file name seem a bit suspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted about2. I don't need it to show:
services.AddMvc()
.AddRazorPagesOptions(options =>
{
options.Conventions.AddFolderApplicationModelConvention(
"/subFolder",
model => model.Filters.Add(new SampleAsyncPageFilter(_logger)));
});
|
||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
// .UseStartup<StartupSync>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I formatted the commented out code but I need all 3 startup class references to test the 3 startup classes - depending on what I want to show.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okies
@@ -0,0 +1,53 @@ | |||
using Microsoft.AspNetCore.Builder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
options.Conventions.AddFolderApplicationModelConvention( | ||
"/subFolder", | ||
model => model.Filters.Add(new SampleAsyncPageFilter(_logger))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there value in showing a sync and async filter being added globally? I'd pick one as long as we show a sample of a sync filter and an async filter being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sample is to show AddFolderApplicationModelConvention
In the rendered document, this async filter is shown in the previous snippet.
@@ -0,0 +1,37 @@ | |||
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, do we always include all the css \ scripts with these samples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lost that battle long ago. I used to exclude them with .gitignore and require you to manually override the ignore file. Now I ask folks to manually exclude them which is usually forgotten.
aspnetcore/toc.md
Outdated
@@ -246,7 +249,6 @@ | |||
### [Build Docker images](/dotnet/articles/core/docker/building-net-docker-images) | |||
### [Visual Studio Tools for Docker](xref:host-and-deploy/docker/visual-studio-tools-for-docker) | |||
### [Publish to a Docker image](https://azure.microsoft.com/documentation/articles/vs-azure-tools-docker-hosting-web-apps-in-docker/) | |||
## [Proxy and load balancer configuration](xref:host-and-deploy/proxy-load-balancer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Fixes #5754
Review URL
Clean up of Filters in ASP.NET Core