asp.net生成静态页面
public static void GetHtml(string url,string savepath)//url参数为将要生成的那个动态页面的地址,savepath为要存放地址
{
string Result;
WebResponse MyResponse;
WebRequest MyRequest = System.Net.HttpWebRequest.Create(url);
MyResponse = MyRequest.GetResponse();
using (StreamReader MyReader = new StreamReader(MyResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8")))//这里根据网站的编码格式而定
{
Result = MyReader.ReadToEnd();
MyReader.Close();
}
FileStream fs = new FileStream(savepath, FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("utf-8"));
sw.WriteLine(Result);
sw.Close();
fs.Close();
}
相关文档:
ASP.NET用URL传递中文参数一般会失败,原因是在获取参数之后进行了编译转换。
可能过修改web.config文件让URL正常传递中文参数
在System.web节添加
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312"/>
即可 ......
在Global.asax中导入命名空间
<%@Global ...
<%@Import Namespace= "System.Data " %>
<%@Import& ......
Private static readonly object ReflectionLock = new object();
Lock (ReflectionLock)
{
Type scriptManagerType =
Type.GetType(
"System.Web.UI.ScriptManager, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35",
false);
......
今天第一天开通了博客,心情乐滋滋的,因为可以和园子里的朋友一起研究技术了。我希望把平时在项目中积累的知识以及自己学习的知识同园子里的朋友分享分享。为我们园子的壮大付出自己的一点努力。这是我发表的第二篇话题,希望对这<%%>语法不熟悉的朋友提供帮助,对已经熟悉的朋友,希望能提出你们宝贵的意见。
在a ......
因为用户的一些对象, 可能在config里进行配置, 但是config怎么能随便让你添加自己的节点呢! 不行你自己试试, 在任何位置添加任何没有申明的节点, 系统都不会让你通过, 更不会让你去读它了, 当然, 你打算在别的xml文件里添加节点, 然后读出来, 创建对象, 这个没问题. 为了系统能有组织的管理用户的在配置文件里的自定义信息 ......