How Can I open the Text file in my MVC application?
asp.net-mvc, c#, javascript, jquery
Solution
You can use this code:
public ActionResult Log()
{
var fileContents = System.IO.File.ReadAllText(Server.MapPath("~/Views/Builder/TestLogger.txt"));
return Content(fileContents);
}
Problem
I want to fetch the Text data from a Text file :: For that, I have used code like :: ``` public ActionResult Log() { StreamReader reader = new StreamReader(Server.MapPath("~/Views/Builder/TestLogger.txt")); return View(reader); } ``` I have made this text file from "Log4Net". I wat to know that How can I fetch the contents of this Text file in my "View" or "action" of MVC application.