Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 368023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:47:03+00:00 2026-05-12T13:47:03+00:00

i’m trying to use OutputCaching in my ASP.NET MVC website. Problem is, when i

  • 0

i’m trying to use OutputCaching in my ASP.NET MVC website. Problem is, when i try and change the value of one my querystring params, it’s returning the data for the first item that was requested!

Here’s my code (with the param names changed) …

[ApiAuthorize]
[HandleErrorAsJson]
public class SearchController : Controller
{
    [AcceptVerbs(HttpVerbs.Get)]
    [OutputCache(Duration = 60, VaryByParam = "*")]
    public ActionResult ScoreCard(string foo, byte? bar, byte? pewpew)
    {
    ..
    }
}
  • NOTE 1: ApiAuthorize – custom attribute that checks for a querystring param called ‘Key’ and checks an in memory dictionary, to see if it exists.
  • NOTE 2: HandleErrorAsJson – custom attribute that returns the error message as json if an exception was/is thrown.

and here’s two sample calls i’m making to this action :-

  • /GET http://api.MySite.com/search/scorecard?foo=hello+world,+PewPew&key=abcd1234&bar=2
  • /GET http://api.MySite.com/search/scorecard?foo=invalid+search+stuff&key=abcd1234&bar=2

so the data from the first call (foo = hello world, Pew Pew) is returned as a 200 OK.
Then the second api call returns a 200 OK but with the data from the previous call.

Also, i’m not using any proxy server.
If i comment out the OutputCache attribute, all is good.

I’ve also tried the following (manually listing each time i need to cache) …..

[OutputCache(Duration = 60, VaryByParam = "foo,key,bar,pewpew")]

No luck 🙁

Notice how i need to make sure that i include the API ‘Key’ parameter as part of the cache unique key. I don’t want to people to search for the same thing, but if the second person doesn’t have the right key, they shouldn’t get a cached result, but an error message (techinically, it’s a 401 Not Authorised, but anyways)…

Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:47:04+00:00Added an answer on May 12, 2026 at 1:47 pm

    The list of parameters in VaryByParam is supposed to be semicolon delimited, not comma delimited. Give that a try. That said, the * should have worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.