换行符在FileContentResult中不起作用,文件文本是一行

时间:2017-10-28 04:58:42

标签: asp.net .net byte newline actionresult

出于某种原因,下面的文字,一旦完成下面的操作,就会创建一条直线,而不是考虑new line characters (\n)。它们是否会被FileContentResultGetBytes删除,如果有,我可以解决这个问题吗?

"<div id=\"exp-schedule-93943\" data-href=\"https://localhost:2222/widgets/v1/schedule?eventid=93943\" data-responsive=\"true\" data-protocol=\"https\" data-width=\"100%\" data-height=\"500px\"></div>\n<script type=\"text/javascript\">\n   (function (d, s, id) {\n   var js, fjs = d.getElementsByTagName(s)[0];\n   if (!d.getElementById(id)) {\n       js = d.createElement(s);\n       js.id = id;\n       js.async = true;\n       js.src = \"https://localhost:2222/scripts/exposure.widgets.min.js\";\n       fjs.parentNode.insertBefore(js, fjs);\n   }\n   })(document, \"script\", \"exp.widgets\");\n</script>"

控制器操作

public virtual ActionResult Download(string text, string fileName)
        {
            var contentDisposition = new ContentDisposition
            {
                FileName = fileName,
                Inline = false,
            };

            Response.AppendHeader("Content-Disposition", contentDisposition.ToString());
            return File(Encoding.UTF8.GetBytes(text), "text/plain");
        }

TEXT.TXT

<div id="exp-events-19185" data-href="https://basketball.exposureevents.com/widgets/v1/events?organizationid=19185" data-css="https://cdn.exposureevents.com/content/external/bballshowcase.min.css" data-responsive="true" data-protocol="https" data-width="100%" data-height="500px"></div><script type="text/javascript">   (function (d, s, id) {   var js, fjs = d.getElementsByTagName(s)[0];   if (!d.getElementById(id)) {       js = d.createElement(s);       js.id = id;       js.async = true;       js.src = "https://basketball.exposureevents.com/scripts/exposure.widgets.min.js";       fjs.parentNode.insertBefore(js, fjs);   }   })(document, "script", "exp.widgets");</script>

0 个答案:

没有答案
相关问题