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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:04:46+00:00 2026-05-26T18:04:46+00:00

I have a post action Import: public ActionResult Import() { var fileNames = new

  • 0

I have a post action Import:

public ActionResult Import()
{
    var fileNames = new List<String>();

    foreach (string path in Directory.GetFiles(directoryPath))
    {
        //do a whole bunch of stuff
        ...
        fileNames.Add(path.Split('\\').Last());            
    }

    return RedirectToAction("Index", new { InvalidFiles = fileNames });
}

As you can see, it redirects to an Index action, passing the List<String> of file names

public ActionResult Index(List<String> InvalidFiles)
{
    return View();
}

In the Index action, the List comes in with the right amount of elements, however all the actual strings has been changed from the filename to the string “System.Collections.Generic.List`1[System.String]”.

Any idea why this is happening? Is there a better way to pass the list to the new action, possibly using TempData?

  • 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-26T18:04:47+00:00Added an answer on May 26, 2026 at 6:04 pm

    You can use TempData to temporally hold the data between actions.

    public ActionResult Import()
    {
        var fileNames = new List<String>();
    
        foreach (string path in Directory.GetFiles(directoryPath))
        {
            //do a whole bunch of stuff
            ...
            fileNames.Add(path.Split('\\').Last());            
        }
    
        TempData["fileNames"] = fileNames;
    
        return RedirectToAction("Index");
    }
    
    
    public ActionResult Index()
    {
        var invalidFiles = TempData["fileNames"] as List<String>;
    
        return View();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a POST controller action like: if (ModelState.IsValid) { try { //.. save
I have a post html form, and the action is index.php, which is the
I have an action handling a form post, but I want to make sure
I have an action which I need to post forward onto another action if
I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:=Id)> <ModelBinder(GetType(CustomModelBinder))> ByVal object As
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
This is working, but how??? I have a controller action for a post: [AcceptVerbs(HttpVerbs.Post
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
resources :patients do collection do get 'new_import' post 'import' end How can I have
i have this problem to find a particular xml node l have post 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.