我想知道你是否做了类似的事情
public FileResult result()
{
Stream stream = new Stream();
return File(stream,"text/html","bob.html");
}
Run Code Online (Sandbox Code Playgroud)
如果File()会关闭你的流?因为我试图将"stream"放在using语句中,但它总是给我一个错误,说流已关闭.
public FileResult result()
{
using(Stream stream = new Stream())
{
return File(stream,"text/html","bob.html");
}
}
Run Code Online (Sandbox Code Playgroud)
如果您使用该File对象将结果文件作为bob.html发送以供下载,则为是.
我相信所有标准Streams(OutputStream,FileStream,CryptoStream)将在关闭或处置时尝试刷新.
MVC框架中有许多实现基FileResult类的类.
System.Web.Mvc.FileResult
System.Web.Mvc.FileContentResult
System.Web.Mvc.FilePathResult
System.Web.Mvc.FileStreamResult
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2653 次 |
| 最近记录: |