zoukankan
html css js c++ java
从Discuz!NT v2.0扣出来的生成静态页面的方法
asp.net下生成静态页的方法有很多,目前我尝试过的方法4-5种,前几天在看Discuz!NT v2.0的源码时,发现了下面的代码。原理很简单,不啰唆了,直接看代码好了:
///
<summary>
///
转换为静态html
///
</summary>
public
void
transHtml(
string
path,
string
outpath)
{
Page page
=
new
Page();
StringWriter writer
=
new
StringWriter();
page.Server.Execute(path, writer);
FileStream fs;
if
(File.Exists(page.Server.MapPath(
""
)
+
"
"
"
+
outpath))
{
File.Delete(page.Server.MapPath(
""
)
+
"
"
"
+
outpath);
fs
=
File.Create(page.Server.MapPath(
""
)
+
"
"
"
+
outpath);
}
else
{
fs
=
File.Create(page.Server.MapPath(
""
)
+
"
"
"
+
outpath);
}
byte
[] bt
=
Encoding.Default.GetBytes(writer.ToString());
fs.Write(bt,
0
,bt.Length);
fs.Close();
}
查看全文
相关阅读:
什么是shell
Jenkins+python+selenium持续继承自动化测试
selenium+python自动化
产品和项目的概念
继承与派生:赋值兼容规则(转)
继承与派生:虚基类及其派生类的构造函数(转)
重载函数与函数模板(转)
继承与派生:作用域分辨符(转)
作用域和可见性(转)
继承与派生:派生类的析构函数(转)
原文地址:https://www.cnblogs.com/leeolevis/p/1383188.html
最新文章
Unity3D 渲染统计窗口
U3D 性能优化
Unity3d优化之路
Unity3D之AssetBundle资源加载封装
lodash源码分析之chunk的尺与刀
读lodash源码之从slice看稀疏数组与密集数组
读Zepto源码之Data模块
读Zepto源码之Form模块
读Zepto源码之Stack模块
读Zepto源码之fx_methods模块
热门文章
读Zepto源码之Fx模块
读Zepto源码之IOS3模块
读Zepto源码之Gesture模块
读Zepto源码之Touch模块
webdriver元素定位
pycharm的安装教程
postman接口测试
小程序微信开发者调试
jmeter性能测试案例分析
jmeter 查看结果树的数据不全解决方案
Copyright © 2011-2022 走看看