zoukankan
html css js c++ java
页面执行时生成静态文件的方法
protected
override
void
Render(HtmlTextWriter writer)
{
if
(EnableStaticFile)
{
if
(transferToHtml)
return
;
string
authorPath
=
Server.MapPath(
"
/authors/
"
+
GetUrlPath(authorID)
+
"
.html
"
);
string
authorDir
=
Path.GetDirectoryName(authorPath);
if
(
!
Directory.Exists(authorDir))
{
Directory.CreateDirectory(authorDir);
}
TextWriter ioWriter
=
null
;
HtmlTextWriter hioWriter
=
null
;
try
{
ioWriter
=
new
StreamWriter(authorPath,
false
, Response.ContentEncoding);
hioWriter
=
new
HtmlTextWriter(ioWriter);
base
.Render(hioWriter);
}
catch
(Exception)
{ }
finally
{
if
(ioWriter
!=
null
) ioWriter.Close();
if
(hioWriter
!=
null
) hioWriter.Close();
}
}
base
.Render(writer);
}
如上代码,重写Page的Render方法,新建一个指向文件的HtmlTextWriter在页面输出之前执行base.Render(txtWriter)即可。非常简单。
查看全文
相关阅读:
宣化上人:大佛顶首楞严经四种清净明诲浅释(4-5)(转自学佛网:http://www.xuefo.net/nr/article23/230699.html)
宣化上人:大佛顶首楞严经四种清净明诲浅释(6-7)(转自学佛网:http://www.xuefo.net/nr/article23/230700.html)
宣化上人: 大佛顶首楞严经四种清净明诲浅释(8-9)(转自学佛网:http://www.xuefo.net/nr/article23/230825.html)
[我的CVE][CVE-2017-15708]Apache Synapse Remote Code Execution Vulnerability
Ubuntu bash不记录history方法
[我的CVE][CVE-2017-15709]Apache ActiveMQ Information Leak
java.lang.Runtime.exec() Payload Workarounds
CVE-2017-12149 JBOOS AS 6.X 反序列化漏洞利用
Apache Continuum 远程命令执行漏洞
docker 端口映射iptables: No chain/target/match by that name错误解决方法
原文地址:https://www.cnblogs.com/yukaizhao/p/dot_net_generate_static_file.html
最新文章
NTPD工作原理介绍
linux时间同步ntpd、ntpdate介绍
如何在 Ubuntu 上设置时间同步
Linux 时间同步systemd-timesyncd介绍
VirtualBox 虚拟机与主机时间同步问题
Linux下使用timedatectl命令时间时区操作详解
linux时间管理与配置date与hwclock命令
Ubuntu18.04安装AMD显卡驱动
国内常用的NTP时间源同步服务器汇总
《往生论注闻记》学修总结
热门文章
淨空法師:【清淨心生百善,根是看破,本是放下】
净空法师:知是看破,行是放下,到底哪个难?给诸位说,知难,看破难
净空法师:爱情与婚姻
释净空:真心的人恭敬、谦卑
释净空:佛号功夫得力,得力在哪里?
净空法师:宇宙人生的真相
首播 | 學習《神愛世人》-第19集
刘善人:好病方法
宣化上人:大佛顶首楞严经四种清净明诲浅释(1)(转自学佛网:http://www.xuefo.net/nr/article23/230609.html)
宣化上人:大佛顶首楞严经四种清净明诲浅释(2-3) -------------------------------------------------------------------------------- (转自学佛网:http://www.xuefo.net/nr/article23/230612.html)
Copyright © 2011-2022 走看看