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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:08:15+00:00 2026-06-04T17:08:15+00:00

customers is a List<string> . RedirectToAction(ListCustomers, new { customers = customers }); And when

  • 0

customers is a List<string>.

RedirectToAction("ListCustomers", new { customers = customers }); 

And when I send the list it contains 4 items, but when I receive it in my controller method it has only one item and it’s of type generic list. That seems not be what I want. But how to pass more complex data than strings and integer between controller methods?

  • 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-04T17:08:17+00:00Added an answer on June 4, 2026 at 5:08 pm

    You cannot send complex objects when redirecting. When redirecting you are sending a GET request to the target action. When sending a GET request you need to send all information as query string parameters. And this works only with simple scalar properties.

    So one way is to persist the instance somewhere on the server before redirecting (in a database for example) and then pass only an id as query string parameter to the target action which will be able to retrieve the object from where it was stored:

    int id = Persist(customers);
    return RedirectToAction("ListCustomers", new { id = id });
    

    and inside the target action:

    public ActionResult ListCustomers(int id)
    {
        IEnumerable<string> customers = Retrieve(id);
        ...
    }
    

    Another possibility is to pass all the values as query string parameters (be careful there’s a limit in the length of a query string which will vary among browsers):

    public ActionResult Index()
    {
        IEnumerable<string> customers = new[] { "cust1", "cust2" };
        var values = new RouteValueDictionary(
            customers
                .Select((customer, index) => new { customer, index })
                .ToDictionary(
                    key => string.Format("[{0}]", key.index),
                    value => (object)value.customer
                )
        );
        return RedirectToAction("ListCustomers", values);
    }
    
    public ActionResult ListCustomers(IEnumerable<string> customers)
    {
        ...
    }
    

    Yet another possibility is to use TempData (not recommended):

    TempData["customer"] = customers;
    return RedirectToAction("ListCustomers");
    

    and then:

    public ActionResult ListCustomers()
    {
         TempData["customers"] as IEnumerable<string>;
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I need to display a list of customers, but only want to
I have a list of Customers. Each customer has an address and some customers
I have a Generic List as below public static readonly List<Customer> Customers = new
I have a problem displaying my Ext.list component. Here is my code: Ext.define(iphone.view.customers.List, {
I have an asp.net mvc application and I'm using Webgrid to list customers. I
I have a List of customers that I'm trying to bind to a DataGridView.
In our application there's a list of customers, and a list of keywords (among
I have a form with a DataGridView showing a list of customers, and some
Currently I am searching through my list to find Customers that match on Address.
List<Customer> _customers = getCustomers().ToList(); BindingSource bsCustomers = new BindingSource(); bsCustomers.DataSource = _customers; comboBox.DataSource =

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.