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 1036325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:41:08+00:00 2026-05-16T14:41:08+00:00

In ASP.NET MVC2 I use OutputCache and the VaryByParam attribute. I got it working

  • 0

In ASP.NET MVC2 I use OutputCache and the VaryByParam attribute. I got it working fine with a single parameter, but what is the correct syntax when I have several parameters on the method?

[OutputCache(Duration=30, VaryByParam = "customerId"]
public ActionResult Index(int customerId)
{
//I've got this one under control, since it only has one parameter
}

[OutputCache(Duration=30, VaryByParam = "customerId"]
public ActionResult Index(int customerId, int languageId)
{
//What is the correct syntax for VaryByParam now that I have a second parameter?
}

How do I get it to cache the pages using both parameters? Do I enter add the attribute twice? Or write “customerId, languageId” as the value??

  • 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-16T14:41:08+00:00Added an answer on May 16, 2026 at 2:41 pm

    Valid values for VaryByParam are one of the following:

    • The literal string * (asterisk), which varies by all parameters of the action method.
    • The literal string none (case-insensitive), which varies by no parameters of the action method.
    • A string containing the semicolon-separated names of the parameters you wish to vary by.

    In your case, you’d want the first option:

    [OutputCache(Duration = 30, VaryByParam = "*")]
    public ActionResult Index(int customerId, int languageId)
    {
    }
    

    If, however, you had some params you want to vary by and some that you don’t, then you’d use the third option:

    [OutputCache(Duration = 30, VaryByParam = "customerId;languageId")] // foo is omitted
    public ActionResult Index(int customerId, int languageId, int foo)
    {
    }
    

    Reference.

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

Sidebar

Related Questions

I try to use ELMAH on my ASP.NET MVC2 application, it works fine on
I've got three C# ASP.NET MVC2 projects within a single solution. Names have been
I'm working on an ASP.Net MVC2 application and use the jsTree-Komponent for jQuery to
I'm using xval to use client side validation in my asp.net mvc2 web-application. Despite
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
How do I use the ASP.NET MVC 2 Preview 2 Futures RequireHttps attribute? I
Here is the ASP.Net MVC2 code that I use to display a textbox input.
I want to use System.Net.Mail.SendAync in an ASP.NET MVC2 application. I see that it
I am planning to use ASP.NET MVC2 implemented membership system to manage users. Database
We've an ASP.Net MVC2 web app (SQL 2008 in backend). We use Data Annotations

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.