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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:07:17+00:00 2026-06-11T14:07:17+00:00

I am passing a List<Listing> object to another action method and making that method

  • 0

I am passing a List<Listing> object to another action method and making that method call a View with the parameter.

For some reason, the parameter which I am passing is null.

The following works fine:

        public ActionResult SortListing(string categoryGuid)
    {
        var listingCategory = new ListingCategory();
        listingCategory = _tourismAdminService.GetByGuid<ListingCategory>(Guid.Parse(categoryGuid));
        var listings = new List<Listing>();

        foreach (var listing in _tourismAdminService.ListAllEntities<Listing>())
        {
            if (listing.CategoryId == listingCategory.Id)
            {
                listings.Add(listing);
            }
        }

        return RedirectToAction("Index", "Listing", listings);
    }

The following shows a Parameter which is coming up as null.

        public ActionResult Index(List<Listing> listing)
    {
        var model = new ListListingsViewModel();
        IEnumerable<ListingCategory> categories = _service.ListAllEntities<ListingCategory>();

        if (categories != null)
        {
            model.Categories =
                categories.Select(
                    cat =>
                    new SelectListItem
                        {
                            Text =
                                cat.GetTranslation(stringA,
                                                   stringB).Name,
                            Value = cat.Guid.ToString()
                        }).ToList();
        }
        model.Listings = listing ?? _service.ListAllEntities<Listing>();

        return View(model);
    }

EDIT

Error Message:

The ViewData item that has the key ‘SelectedCategoryGuid’ is of type ‘System.Guid’ but must be of type ‘IEnumerable’.

On:

@Html.DropDownListFor(
m => m.SelectedCategoryGuid, 
Model.Categories, 
"Select a Category", 
new {
    id = "hhh",
    data_url = Url.Action("SortListing", "Listing") 
}
  )
  • 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-11T14:07:19+00:00Added an answer on June 11, 2026 at 2:07 pm

    RedirectToAction method returns a Http 302 response to the browser,which cause the browser to make a GET request to the specified action.

    Remember HTTP is stateless. You can not pass such complex object like that.

    You should either pass a querystring (an Id) and get the value in the second action again or keep the data in a persitant medium between the calls. You may consider using Session or TempData (session is the backed up storage for that) for that.

    http://rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications

    EDIT : As per the comment. Yes you can call the view from the first method itself. the below code will pass the string collection the Index view (index.cshtml).

    public ActionResult SortedList(string categoryGuid)
    {
       var listings = new List<Listing>();
       //fill the collection from the data from your db
       return View("Index",listings)
    }
    

    If you want to pass the data to a view in a different controller, you can specify the full path when calling the View method.

    return View("~/Views/User/Details.cshtml",listings)
    

    Assuming your view is strongly typed to a list of strings like this

    @model List<string>
    foreach(var item in Model)
    {
     <p>@item</p>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm passing a List to an MVC view and generating checkboxes for each object
I have a controller action which passes a list of products to the view.
Im using a BaseAdapter and passing to it a List of objects that have
Is there a simple way of passing a list as the parameter to a
I am passing a list to a view. My array looks like this: [football,
Hi i'm passing a List object from my controller to Javascript where it is
i'm new at this tecnology and i'm having some trouble passing a list of
I am passing a list to the view from Controller. How can i generate
I have an action method that looks like this: public ActionResult DoSomething(string par, IEnumerable<string>
In Edit view: I am passing ViewBag list for the ddl Controller: ViewBag.CountryList =

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.