我使用'另存爲html'將文件另存爲html。 我的代碼是:我想代碼保存html中的C#
string fileName = "";
string htmlpfilepath;
string[] parts;
try
{
htmlpfilepath = Server.MapPath(ClinicalDocFile);
parts = ClinicalDocFile.Split('/');
if (parts.Length > 0)
fileName = parts[parts.Length - 1];
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "text/HTML");
response.AddHeader("Content-Disposition",
"attachment; filename=" + fileName + "; size=" + fileName.Length.ToString());
response.Flush();
response.WriteFile(htmlpfilepath);
response.Flush();
response.End();
}
catch (Exception ex)
{
FW.Fission.WebSite.Code.Utilities.SiteUtilities.HandleException(ex);
}
我收到以下錯誤response.End();
線。
啓用以評估表達式,因爲代碼已經過優化或本機框架位於調用堆棧之上。
這不是程序錯誤。這是一個調試器問題。你在調試模式下運行嗎? – Gusdor
它只告訴你它不能告訴你真正的錯誤是什麼。在你的項目屬性 - >構建檢查「優化代碼」,然後看看有什麼錯誤說。當然,你必須重建 –
我得到同樣的錯誤。 –