ashx时“文档的顶层无效”的处理办法

连接地址:转载请标明原作者的地址

http://www.cnblogs.com/zhukezhuke/archive/2010/12/20/1911608.html

解决的办法是
context.Response.ContentType = "text/plain";


把这行去掉或注释掉

解释如下:

<> Response.ContentType :控制输出的文件类型 
< src="../flashtop/ViewFileScript.js"> 服务器送给客户端的数据包类型可以是text/html文本,也可以是gif/jpeg图形文件,所以每次传输前,我们都必须告知客户端将要传输的文件类型,一般默认情况下为“Text/Html”类型。
<% Response.ContentType = "text/HTML" %>
<% Response.ContentType = "image/GIF" %>
<% Response.ContentType = "image/JPEG" %>
<% Response.ContentType = "text/plain" %>
<% Response.ContentType = "image/JPEG" %>
<% Response.ContentType = "application/x-cdf" %>
用于作为文本内容返回而不是已解释的 HTML 语句
Response.ContentType = "text/plain"

原文地址:https://www.cnblogs.com/xingchen/p/2140226.html