title: Upload and Process File ASP.NET MVC 3
body: <p>I'm new to ASP.NET and MVC3 and I'm trying to figure out how to upload a file and process its contents and then display the results in a view.  </p>
  
  <p>I can successfully upload a file using the following view code:</p>
  
  <pre><code>@using (Html.BeginForm("Index", "Home", FormMethod.Post, new {
  id="UploadForm",
  enctype = "multipart/form-data"})){
  &lt;input type="file" name="file" id="Upload" size="60" /&gt;
  &lt;input type="submit" value="Submit" id="submitID" /&gt; }
  </code></pre>
  
  <p>...And the following controller code:</p>
  
  <pre><code>public ActionResult Index(HttpPostedFile file) {
  if (file != null &amp;&amp; file.ContentLength &gt; 0) {
  var filename = Path.GetFileName(file.FileName);
  var path = Path.Combine(Server.MapPath("~/REPO"), fileName);
  file.SaveAs(path); }
  return RedirectToAction("Index"); }
  </code></pre>
  
  <p>What I can't quite figure out is how to proceed after I've uploaded the file:  I want to execute a server-side code to read the file contents and then display the results on the index view.</p>
  
  <p>So this is what I want to do:</p>
  
  <ol>
  <li>Redirect to some process (controller action)</li>
  <li>Pass the file name in a string to the action</li>
  <li>Read the file using the server-side program to produce an output (this part is already coded in C# and outputs a string from a string input)</li>
  <li>Pass that string back to the index view controller to display on the page</li>
  </ol>
  
  <p>What do I do?  Please be explicit with an answer, and not assume too much, because as I said, I am relatively new to ASP.NET and MVC (~2 weeks).  Thanks for your help!</p>