title: Mvc : displaying a List<student> from the database in a text file with click of button
body: <p>I am new to mvc. I have a controller with two methods. I want to return a list to a text
  file on the click of a button. I have been trying to figure out a way how I can pass
  the list to the CreateReportFile method but no luck. It works very well for stringbuilder objects.</p>
  
  <p>Do you have an idea of how I can display the List in a text file? </p>
  
  <pre><code>@Html.ActionLink("Download File", "CreateReportFile");
  
  
           public FileStreamResult CreateReportFile()
                  {
                      //todo: add some data from your database into that string:
                      var string_with_your_data = string.Empty;              
                      var byteArray = Encoding.ASCII.GetBytes(string_with_your_data);
                      var stream = new MemoryStream(byteArray);
                      return File(stream, "text/plain", "Report" + DateTime.Now + ".txt");
                  }
  
  
  
                  public List&lt;Student&gt; GetStudents()
                  {
                      return new List&lt;Student&gt;()
                      {
                          new Student() {firstname="james",lastname="john",emailAddress="james.john@yahoo.com"},
                          new Student() {firstname="patric",lastname="swayze",emailAddress="patric.swayze@yahoo.com"},
                          new Student() {firstname="james",lastname="john",emailAddress="james.john@yahoo.com"},
                          new Student() {firstname="toy",lastname="gas",emailAddress="toy.gas@yahoo.com"}
                      };
                  }
  </code></pre>