I am learning ASP.Net MVC 4 Programming. Currently, I want to display the list of files to the web page. Following is what I did till now.
In the HomeController.cs I edited the Contact action as follows:
public ActionResult Contact()
{
ViewBag.Message = "Your file page.";
DirectoryInfo dirInfo = new DirectoryInfo(@"c:\");
List<string> filenames=dirInfo.GetFiles().Select(i=>i.Name).ToList();
ViewBag.data = filenames;
///^^ Is this correct??
return View();
}
I want the filenames to be displayed to the web page. What should I write in my view? I right clicked the Contact action and got the default view, containing:
@{
ViewBag.Title = "Contact";
}
<h2>Contact</h2>