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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:05:29+00:00 2026-05-27T09:05:29+00:00

When passing a RouteValueDicitonary or anonymous object into a @Url.Action method (or any of

  • 0

When passing a RouteValueDicitonary or anonymous object into a @Url.Action method (or any of its analogs), is there a way to properly pass in a collection object or IEnumerable so that it would generate a url that would be compatible with the default model binder?

For example, say I have an action like this:

public ActionResult Index(ICollection<int> ids)
  {
    ...do something
  }

and in my template I do something like this:

@Url.Action("Index", routeValues:new int[]{1,2,3})

the goal is to have a url output like this:

... /index?ids=1&ids=2&ids=3

but the url output is actually something like this:

... /index?ids=System.Int[]

I’m assuming there is no support for this currently. If not, then at what part in MVC do I need to create a custom handler or whatever to override this default functionality?

  • 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-27T09:05:29+00:00Added an answer on May 27, 2026 at 9:05 am

    Unfortunately currently there is no existing helper that will allow you to generate such url. So one possibility is to do it manually:

    @(Url.Action("Index") + "?" + string.Join("&", new int[] { 1, 2, 3 }.Select(x => "ids=" + x)))
    

    or write an extension method to encapsulate the logic:

    @Url.ActionWithIds("Index", new int[] { 1, 2, 3 })
    

    Since those are integers we don’t need url encoding but if you want to do the same thing with a collection of strings the values should be properly url encoded.

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

Sidebar

Related Questions

Passing an object by reference is an easier, faster and safer way to pass
After passing an object into a method, I would like to change one of
If I am passing an object to a method, why should I use the
Passing parameters is common in daily programming, but should we pass parameters as object
In my plugin architecture I am currently passing a plugin name (string), method name
When passing forward declared struct or a class, one has to pass it to
I am passing a string from objective C to javascript in this way -
when passing EqualityComparer as last parameter to Linq Join method it is not using
Am passing some parameters through in Struts2, and am getting below error when there
Passing parameters works with 2 normal activities, but when I try to pass this

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.