Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Add support for ResponseCache in Razor Pages #6627

Closed
wants to merge 2 commits into from
Closed

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Aug 3, 2017

Fixes #6437


namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
{
public class ResponseCacheFilterApplicationModelProvider : IPageApplicationModelProvider
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests for this because I wasn't sure if there's a specific reason controllers use the filter factory route to add the actual filter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's fine as long as there's a functional test (which there is)

@@ -41,17 +30,17 @@ public ResponseCacheFilter(CacheProfile cacheProfile)
/// </summary>
public int Duration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have these properties?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you can still construct the filter

/// </summary>
public interface IResponseCacheFilter : IActionFilter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a different marker type for pages? I thought we were kinda ok changing this since it's in .Internal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! it is, cool. Ok that's all fine then

_cacheProfile = cacheProfile ?? throw new ArgumentNullException(nameof(cacheProfile));
}

public int Duration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than duplicating all of this, it would be better pass in the ResponseCacheFilter object directly - similar to how our action result executors work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two different types of ResponseCacheFilter though. I didn't want to go down the inheritance route because that seemed gross.

// Assert
Assert.Collection(
context.PageApplicationModel.Filters,
f => { },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda annoying. ResponseCacheAttribute is a IFilterFactory and ends up adding ResponseCacheFilter : IActionFilter to the model. It ultimately does nothing, but it would be nice if we could avoid having it in the list at all.

@pranavkm
Copy link
Contributor Author

pranavkm commented Aug 4, 2017

Added test 🆙 📅

@pranavkm pranavkm closed this Aug 24, 2017
@pranavkm pranavkm deleted the prkrishn/6604 branch August 24, 2017 21:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants