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();
}
查看全文
相关阅读:
杨辉三角(hdu2032)——有待完善
求平均成绩(hdu2023)
绝对值排序(2020)——笔记待完善
母牛的故事(hdu2018)——笔记待完善
29.数据结构---栈,队列,数组,链表,哈希表
16.PR将视频剪辑成任意形状
28.集合1------List
IDEA选中多行代码向左右移动缩进
27.集合1------Collection
IDEA显示单个文件结构
原文地址:https://www.cnblogs.com/chenjunbiao/p/1760260.html
最新文章
函数模板的概念和意义
关于继承中的强制类型转换
构造函数、析构函数能否定义成虚函数以及在其内能够发生多态行为
动态内存的分配(new delete malloc free)
第53课 被遗弃的多重继承 (下)——正确的使用多重继承
第53课 被遗弃的多重继承 (中)
第53课 被遗弃的多重继承
断剑重铸014 完结
9.接入类流程-接入问题分析
8.接入类流程-接入功率控制
热门文章
7.接入类流程-PRACH优化
6.流程类优化
5.容量优化
4.覆盖优化
Poj1753 翻转棋子
hdu2093 考试排名(还需完善)
手机短号(hdu2081)
单词数(hdu2072)
(STL初步)映射:map
(STL初步)不定长数组:vector
Copyright © 2011-2022 走看看