0
我有一個非常基本的頁面,其中有幾張圖片需要通過相對路徑保存到.html文件中。ASP.NET MVC將視圖保存爲HTML文件
我已經在過去使用過這個,但是在圖像上遇到了問題。
public static class ActionResultExtensions
{
public static string Capture(this ActionResult result, ControllerContext controllerContext)
{
using (var capture = new ResponseCapture(controllerContext.RequestContext.HttpContext.Response))
{
result.ExecuteResult(controllerContext);
return capture.ToString();
}
}
}
public class ResponseCapture : IDisposable
{
private readonly HttpResponseBase _response;
private readonly TextWriter _originalWriter;
private StringWriter _localWriter;
public ResponseCapture(HttpResponseBase response)
{
_response = response;
_originalWriter = response.Output;
_localWriter = new StringWriter();
response.Output = _localWriter;
}
public override string ToString()
{
_localWriter.Flush();
return _localWriter.ToString();
}
public void Dispose()
{
if (_localWriter == null) return;
_localWriter.Dispose();
_localWriter = null;
_response.Output = _originalWriter;
}
}
我想知道如何獲得結果與所有的CSS和圖像與HTML一起下載一個很好的小包裝。
你有問題要問? –
對不起,這是得到提交沒有我的整理 – Ryan
我更新了我的問題的底部 – Ryan