[RESOLVED]ActionResult File not reading the newline


I am listing the txt files from a folder aa a link and opens it in a modal dialog  when clicks on that.

I am listing the files as follows

 <div style="margin-top:5%;">
                @{  if ((Model!=null) && (Model.Count() > 0))
                                             @foreach (var item in Model){
                                                 <li style="padding-top:1%;">
                                                     @Html.ActionLink(item.FileName, "OpenLogFile", "Admin", new { filename = item.FileName }, new { @class = "logfiles" })      

                                            @*@Html.DisplayFor(modelItem => item.FileName)*@

                         <div>  <p class="vpgnorecords">No Log Files found in the directory !!!</p></div>

And the controller action is as follows

 public ActionResult OpenLogFile(string filename)
             FileInfo info = new FileInfo(GetLogFilePath()+"/"+filename);
             return File(info.OpenRead(), "text/plain");

And open this file in a dialog as follows

 $(".logfiles").click(function () {
            var url = $(this).attr('href');
                title: 'Log File Content',
                autoOpen: false,
                resizable: false,
                height: 800,
                width: 1000,

                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                top: '100px',
                left: '50%',
                open: function (event, ui) {

                close: function (event, ui) {

            return false;

The opening div is as follows

<div>  <p class="vpgnorecords">No Log Files found in the directory !!!</p></div>

It opens the corrsponding txt files, but the file content is displaying as a single line without reading the newline character.

Its not reading the enter..its showing the whole content as a single line

How to Show the content as it is in the txt file

Pls help me



You can do one thing,

Store the data retreived from the Action and then on success, load the content as html like:



This would work out.

Load your file into


your file here


rather than


your file here


Leave a Reply