通过stackoverflow中的链接后,我已经厌倦了使用语句,但仍然无法找到确切的解决方案。
using (MemoryStream stream = new MemoryStream(textAsBytes))
{
using (HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(stream)
})
{
httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "main-theme.scss"
};
httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("text/css");
ResponseMessageResult responseMessageResult = ResponseMessage(httpResponseMessage);
return responseMessageResult;
}
}
收到以下错误
CA2000 在方法“GetStyleSheet()”中,对象“new HttpResponseMessage()”未沿所有异常路径处理。在对对象“new HttpResponseMessage()”的所有引用超出范围之前调用 System.IDisposable.Dispose。