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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:48:18+00:00 2026-05-20T12:48:18+00:00

Is it possible to overload the action methods based on number of parameters in

  • 0

Is it possible to overload the action methods based on number of parameters in request?

Eg:

1.
domain.com/List/Filter/ByName
invokes -> public ActionResult Filter(string criteria1)

2.
domain.com/List/Filter/ByName/ByRanking
invokes -> public ActionResult Filter(string criteria1, string criteria2)

I’m using asp.net mvc2.

  • 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-20T12:48:19+00:00Added an answer on May 20, 2026 at 12:48 pm

    If I’m not mistaken the best way to do this would be to add two different controller methods and map them to two different Urls.

    public ActionResult Filter1(string criteria1);
    
    public ActionResult Filter2(string criteria1, criteria2);
    

    Then you have two route definitions:

    This will map this URL List/Filter/xxCriteria/ to the first controller

    routes.MapRoute(
                "Filter",                                              // Route name
                "{controller}/Filter/{criteria1}",                           // URL with parameters
                new { controller = "List", action = "Filter1", criteria="" }  // Parameter defaults
            );
    

    This will map this URL List/Filter/xxCriteriaName/xxxCriteriaRank to the second controller. Without this route you could still map a url to the second method, but it would look like : List/Filter/?criteria1=xx&criteria2=xx

    routes.MapRoute(
                "Filter2",                                              // Route name
                "{controller}/Filter/{criteria1}/{criteria2}",                           // URL with parameters
                new { controller = "List", action = "Filter2", criteria1 = "", criteria2 = "" }  // Parameter defaults
            );
    

    Hope it helped.

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

Sidebar

Related Questions

Is it possible to overload a method on default parameters? For example, if I
It's possible to overload the not operator for a class: class TestA { public:
Is it possible to overload the null-coalescing operator for a class in C#? Say
Is it possible to overload the default function operator (the () operator) in C#?
Why is it not possible to overload a function just by changing the return
Hey. Is it possible to overload operator<< for primitive types? Fx lets say that
Still wrapping my head around Delegates and I'm curious: Is it possible to overload
Hey, I'm trying to figure out if it's possible to overload a template class
Possible Duplicate: Java operator overload In c++, we can perform the operator overloading. But
I have been trying to overload my index method. Here are my index methods:

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.