66
77namespace Web . Pages . Tips ;
88
9- [ OutputCache ( PolicyName = "SearchResults" ) ]
9+ // Disable output caching for this page to prevent form state caching issues
10+ // We'll implement data-level caching in the service layer instead
1011public class IndexModel : BasePageModel
1112{
1213 private readonly IContentService _contentService ;
13- private readonly ILogger < IndexModel > _logger ; // Use default cache duration for tips list (6 hours) since new tips are added infrequently
14- // protected override int CacheDurationSeconds => base.CacheDurationSeconds; // 6 hours default
14+ private readonly ILogger < IndexModel > _logger ;
15+
16+ // Disable page-level caching to prevent form state issues
17+ protected override bool AllowCaching => false ;
1518
1619 public IndexModel ( IContentService contentService , ILogger < IndexModel > logger )
1720 {
@@ -36,13 +39,9 @@ public IndexModel(IContentService contentService, ILogger<IndexModel> logger)
3639
3740 public async Task < IActionResult > OnGetAsync ( )
3841 {
39- // For search results, prevent aggressive browser caching
40- if ( ! string . IsNullOrEmpty ( Search ) || ! string . IsNullOrEmpty ( Category ) ||
41- ! string . IsNullOrEmpty ( Tag ) || ! string . IsNullOrEmpty ( Difficulty ) || PageNumber > 1 )
42- {
43- Response . Headers . CacheControl = "no-cache, must-revalidate" ;
44- Response . Headers . Pragma = "no-cache" ;
45- }
42+ // Set cache headers to prevent browser caching of the HTML form state
43+ Response . Headers . CacheControl = "no-cache, must-revalidate" ;
44+ Response . Headers . Pragma = "no-cache" ;
4645
4746 try
4847 {
@@ -56,6 +55,8 @@ public async Task<IActionResult> OnGetAsync()
5655 PageSize = 12
5756 } ;
5857
58+ Console . WriteLine ( $ "Searching tips with: Category={ Category } , Tag={ Tag } , Search={ Search } , Difficulty={ Difficulty } , Page={ PageNumber } ") ;
59+
5960 var searchResult = await _contentService . SearchTipsAsync ( request ) ;
6061
6162 // Get filter options
0 commit comments