zoukankan
html css js c++ java
使用WebClient后的Response编码的问题
使用WebClient可以抓取别的网页的内容,然后提供下载,但是使用Response输出时要注意编码问题,否则打开是一片空白。使如:
protected
override
void
Render(HtmlTextWriter writer)
{
string
url
=
string
.Format(
"
{0}/con001_projectmanage/job/downloadresume.aspx?resumeid={1}
"
,
Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery,
string
.Empty).TrimEnd(
'
/
'
).ToLower(),
Request.QueryString[
"
resumeid
"
]);
WebClient wb
=
new
WebClient();
byte
[] buf
=
wb.DownloadData(url);
//
从指定的Uri获取数据
Page.Response.Clear();
Response.Charset
=
"
UTF-8
"
;
//
TODO:指定的Charset要与ContentEncoding相一致。
Page.Response.ContentType
=
"
text/html
"
;
Page.Response.AddHeader(
"
content-disposition
"
,
"
attachment; filename=\
"
resume.htm\
""
);
Page.Response.ContentEncoding
=
Encoding.UTF8;
Page.Response.OutputStream.Write(buf,
0
, buf.Length);
Page.Response.Flush();
Page.Response.End();
}
查看全文
相关阅读:
nagios --rhel6.5
nginx+tomcat+msm(memcached-session-manager)
化学实验过程中对眼睛的保护
实验室化学药品取用规则
物理变化、化学变化、物理性质、化学性质
windows 下在图片中隐藏文件
老子《道德经》第六十八章
linux 3.0.35 内核下 include/linux/compiler.h 关于__iomem
boa 服务器进行 cgi 测试时出现 400 Bad Request 【已解决】
linux 内核 arch 目录下处理器体系结构
原文地址:https://www.cnblogs.com/chenjunbiao/p/1760260.html
最新文章
UbuntuLinux安装Mysql
Mysql基于GTIDs的复制
PHP URL 重定向 的三种方法(转载)
linux设置环境变量的方法
买200元送100元,打几折?
http1.0与http1.1的区别
面向对象设计SOLID五大原则
53张牌中找出缺少的牌的花色和点数--raid3,4,5,6的容错原理
抽样问题
用telnet和php的curl库测试http
热门文章
Javascript null和undefined
[转载]求平方根sqrt()函数的底层算法效率问题
pam
安全、加密(gpg)、数字签名
SSL
tunnel
zabbix --监控
centreon ---监控软件
nagios --centos7.3
tomcat--centos7.3
Copyright © 2011-2022 走看看