在ASP.net中打开文件问题 [英] Issue Opening File in ASP.net

查看:69
本文介绍了在ASP.net中打开文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft JScript运行时错误:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器收到的消息.导致此错误的常见原因是通过调用Response.Write(),响应筛选器,HttpModules或服务器跟踪来修改响应.

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '%PDF-1.2
%??
1 0 ob'


尝试在asp.net中打开文件时出现上述错误

我正在使用的代码


I am getting this above error when trying to open file in asp.net

Code which i am using

string ViewFileName = Server.MapPath(DocumentPath + lblHiddenFileName.Text);
 FileInfo infofile = new FileInfo(ViewFileName);
 string myFile = ViewFileName;
 WebClient myWeb = new WebClient();
 Byte[] myBuff = myWeb.DownloadData(myFile);
 Response.Expires = 0;
 Response.CacheControl = "no-cache";
 Response.AppendHeader("Pragma", "no-cache");
 Response.Buffer = true;
 Response.ContentType = contenttype;//"application/pdf";
  Response.AddHeader("Content-Disposition", "attachment; filename=" + infofile.Name);
 Response.BinaryWrite(myBuff);

推荐答案

此处的信息
Sys.WebForms.PageRequestManagerParserErrorException-它是什么以及如何避免 [ http://tgynther.blogspot.com/2009/02/aspnet-updatepanel-and- responsewrite.html [ ^ ]可以帮助您解决问题.
The information here
Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it [^]
and here
http://tgynther.blogspot.com/2009/02/aspnet-updatepanel-and-responsewrite.html[^] may help you solve the problem.


这篇关于在ASP.net中打开文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆