惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - 露雨城市.NET2.0和Sql Server 2005开发研究

我的神龙卡KTV点播软件只有一个遗憾了 关于清除Sql Server Express版本的数据库日志文件 关于微软2008技术预览大会南京站和Vista 也许是转折-放弃了5,6K的月薪 关于vs2005中ajax控件暴露模板中控件,请高手进来聊聊. - 露雨城市.NET2.0和Sql Server 2005开发研究 这个基础题,你能做对吗? 好久没有来发文章了,今天来秀一下。 在.NET2.0中如何更简单的使用委托将方法加载到事件中去 Visual C#中父窗口和子窗口之间实现控件互操作 关于如何在子窗口中选择后,在父窗口赋值并让输入框设为只读。 - 露雨城市.NET2.0和Sql Server 2005开发研究 我的新资源网站开张了,韩国模版,韩国设计资源等。 关于在插入的模版中如何为已绑定了Text属性的TextBox设置默认值 今天好高兴,通过了微软的Sql Server 2005的70-31的考试。 赠送一张微软免费考试券 关于GridView中选择当前行的问题。 VS2005中的一个小BUG:关于Dropdownlist无法Datadinding的解决方法。 如何动态设置全局theme,及在web.config中读取pages节点的内容。 讲故事谈.NET委托:一个C#睡前故事 关于的MasterPage和Theme的问题。
关于asp.net将动态页直接生成静态页的随笔(乱码)
露雨城市.NET2.0和Sql Server 2005开发研究 · 2010-05-15 · via 博客园 - 露雨城市.NET2.0和Sql Server 2005开发研究

最近正在帮一家网站做一些静态页的工作,将一些动态页面直接生成静态页.

老早就知道这个可以用WebClient来实现,用WebClient将动态的页面进行远程读取.

然后将读取的内容写入到相应的静态文件中.说白了就两个动作,读和写而以.

不过在读和写过程中,一定要注意编码要一致,要不然会产生内容乱码或是浏览网页时出现乱码.

而且我看了一下网上解决静态页的方案,太过哆嗦.

今天我就把我最简单的方法来和大家分享一下,也许高手们觉得这个太简单,太普通了,没必要发了.

不过我写的内容都是比较简单的,深入的我也写不了.所以我是写给同样遇到这样烦恼的朋友的.

能产生的共同的,或有更简单方案的朋友记得回复留言哦.

代码

 1 private void MakeHTML(string url,string savefile)
 2     {
 3         WebClient wc = new WebClient();
 4         byte[] bs = wc.DownloadData(url);
 5         string html = Encoding.GetEncoding("GB2312").GetString(bs);        
 6         string saveFile = Server.MapPath(savefile);
 7         StreamWriter sw = new StreamWriter(saveFile, false, Encoding.GetEncoding("GB2312"));
 8         sw.Write(html);
 9         sw.Close();
10     }

posted on 2010-05-15 12:19  露雨城市.NET2.0和Sql Server 2005开发研究  阅读(759)  评论()    收藏  举报