【发布时间】:2014-08-21 01:26:39
【问题描述】:
假设我有一个看起来像这样的 .txt 文件:
heyo.txt:
<p>heyo</p><p>heyo!</p>
如果我希望 heyo.txt 的内容呈现在视图内部的某个位置(例如,在视图完成加载之后),那么我该如何做呢?
有没有办法在 ASP.NET 中以类似于 PHP 的 readfile() 函数的方式完成此任务?我试过使用 Response.WriteFile 没有成功:
@{ Response.ContentType = "text/html"; //(and "text/xml")
Response.WriteFile(Url.Content("~/Content/heyo.txt"));
}
使用“text/html”将整个页面替换为heyo.txt的内容,“text/xml”抛出"XML Parsing Error: junk after document element"。
【问题讨论】:
标签: php html asp.net-mvc-4