Skip to content

Make "Microsoft.AspNetCore.Mvc.Filters.ResponseCacheFilter" public again #14917

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

Closed
sebnilsson opened this issue Oct 11, 2019 · 5 comments
Closed
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question
Milestone

Comments

@sebnilsson
Copy link

After upgrading a project from ASP.NET Core 2.x and .NET Core 2.x to 3.x, I found that Microsoft.AspNetCore.Mvc.Filters.ResponseCacheFilter has become internal.

It previously used to be public, when it was Microsoft.AspNetCore.Mvc.Internal.ResponseCacheFilter.

This brakes existing code, which relies on resolving this filter and modifying it.

@javiercn javiercn added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Oct 11, 2019
@javiercn javiercn reopened this Oct 11, 2019
@javiercn
Copy link
Member

Thanks for contacting us @sebnilsson.

In ASP.NET Core, pubinternal types are types that are declared as public but put in an .Internal namespace. While these types are public they have no support policy and are subject to breaking changes. Unfortunately accidental use of these types has been common, resulting in breaking changes to these projects and limiting our ability to maintain the framework.

If you give us some information on what you were trying to with it, we can try and suggest alternative ways of achieving the same thing.

@pranavkm
Copy link
Contributor

@sebnilsson is there a reason you are unable to use ResposeCacheAttribute? It's how we expect users to configure the filter on their endpoints.

@sebnilsson
Copy link
Author

@pranavkm The current use, which might be done on completely wrong assumptions, is in a custom implementation of ExceptionFilterAttribute.

In the OnException-method, we use context.Filters.OfType<ResponseCacheFilter>().FirstOrDefault() to resolve the filter and reset all properties. This is done to ensure that nothing like storage, location or duration is set for the returned error page.

@pranavkm
Copy link
Contributor

@sebnilsson using the attribute should work just as well here: context.Filters.OfType<ResponseCacheAttribute>().FirstOrDefault()

You could also indiscriminately clear out the cache headers. This is what the exception handling middleware does - https://github.com/aspnet/AspNetCore/blob/master/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddleware.cs#L153-L161. The outcome should no different than what you get with your current check.

@sebnilsson
Copy link
Author

sebnilsson commented Oct 15, 2019

I sort of expected that was the case 😃
Thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question
Projects
None yet
Development

No branches or pull requests

4 participants