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

  • Home
  • SEARCH
  • 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 8800181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:31:10+00:00 2026-06-14T00:31:10+00:00

This is not working for some reason: [OutputCache(Duration = 600, VaryByParam = id)] public

  • 0

This is not working for some reason:

    [OutputCache(Duration = 600, VaryByParam = "id")]
    public string GetSomeValue(int id)
    {
        return _service.GetSomeValue(id).ToString();
    }

I tested this in a controller that returns a View and it does work.

Any idea why? or any possible workaround?

  • 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-06-14T00:31:11+00:00Added an answer on June 14, 2026 at 12:31 am

    The attribute must be placed onto the Action itself not this method

      [OutputCache(Duration = 600, VaryByParam = "id")]
       Public ActionResult Get(int id)
    

    Based on your comment it sounds like you are looking for server caching. I’d recommend something like memcached or Redis but equally you can use the cache built into IIS. Note you must be aware of when your cache should be burst and of how you would deal with distribution if you are on a web farm. In it’s simplest form you could try this

    public string GetSomeValue(int id)
    {
      var cachedItem = HttpRuntime.Cache.Get(id.ToString());
      if(cachedItem==null){
         value = _service.GetSomeValue(id).ToString();
         cachedItem = HttpRuntime.Cache.Add(id.ToString(), value);
      }
      return cachedItem;
    }
    

    The full options of Add give you the chance to set a sliding or absolute expiration

    public object Add(
             string key, 
             object value, 
             System.Web.Caching.CacheDependency dependencies, 
             System.DateTime absoluteExpiration, 
             System.TimeSpan slidingExpiration, 
             System.Web.Caching.CacheItemPriority priority,  
             System.Web.Caching.CacheItemRemovedCallback onRemoveCallback)
    

    Pass in null for dependencies for example but set expiration as you wish.

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

Sidebar

Related Questions

This HTML is not working for some reason... <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
I'm trying this and for some reason is not working. I'm suspecting it may
Im trying to get this working but for some reason it's just not right.
This is not working for some reason. I'm not sure why: objBitmap = new
For some reason this is not working, yet all my searches say it should
For some reason this is not working... Options +FollowSymLinks -MultiViews -Indexes RewriteEngine On RewriteBase
For some reason, this is not working. I am getting: ERROR: is/2: Arguments are
For some reason this is not working. Instead it thinks it should check the
I have added some animation using jquery but it's not working: $('.test-container').click(function(){ $(this).css('background-color', 'rgb(119,
On whatever reason this is not working (says 'file not found'), set in=c:\myprogram\_save cd

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.