当我尝试从asp.net应用程序中的服务器下载文件时出现异常:
这是我的代码:
try
{
Response.AppendHeader("Content-Disposition", "attachment; filename=" + "toto");
Response.TransmitFile(Server.MapPath("fda//toto.txt"));
Response.End();
}
catch (Exception ex)
{
var exception = ex;
}
这是我调试代码并在“catch异常”处设置断点时得到的异常:
ex = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
当我运行我的代码而没有进行调试且没有断点时,我得到了这个:
我的代码停在“ScriptResource.axd ..... acab [动态]页面”行“抛出错误”,并弹出以下视觉工作室:
Sys.WebForms.PageRequestManagerParserErrorException:
弹出窗口上有3个按钮:中断,继续,忽略。