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();
}
查看全文
相关阅读:
边工作边刷题:70天一遍leetcode: day 95
边工作边刷题:70天一遍leetcode: day 96-2
边工作边刷题:70天一遍leetcode: day 96-1
边工作边刷题:70天一遍leetcode: day 96
边工作边刷题:70天一遍leetcode: day 97-3
边工作边刷题:70天一遍leetcode: day 97-2
边工作边刷题:70天一遍leetcode: day 97-1
边工作边刷题:70天一遍leetcode: day 97
边工作边刷题:70天一遍leetcode: day 40
边工作边刷题:70天一遍leetcode: day 41-3
原文地址:https://www.cnblogs.com/chenjunbiao/p/1760260.html
最新文章
django分页的两种方式
django中的中间件
django中的信号
python中的单例模式的应用
mongodb 实用记录
django-admin管理后台高级自定义
mysql字符集的修改
修改django 后台admin用户的密码
通过navigationController跳转界面时隐藏navigationBar上的元素
UI进阶
热门文章
常用宏
iOS9的一些问题
cell跳出动画
短信验证倒计时按钮
Masonry介绍与使用实践:快速上手Autolayout
边工作边刷题:70天一遍leetcode: day 94-2
边工作边刷题:70天一遍leetcode: day 94-1
边工作边刷题:70天一遍leetcode: day 94
边工作边刷题:70天一遍leetcode: day 95-2
边工作边刷题:70天一遍leetcode: day 95-1
Copyright © 2011-2022 走看看