易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net生成静态页的方法





1、直接将页面内容存在变量中后输出: 
 StringBuilder IndexContentResult= new StringBuilder(); //存放输出页面的HTML 
 IndexContentResult.Append("<html>\n"); 
 IndexContentResult.Append("  <head>\n");
 IndexContentResult.Append("    <title>title</title> \n");
 IndexContentResult.Append("  </head>\n");
 IndexContentResult.Append("  <body>\n");
 ...
 IndexContentResult.Append("  <body>\n");
 IndexContentResult.Append("</html>\n");
 string tempfile = Server.MapPath("~");
 tempfile = tempfile + "index.htm";
 System.IO.StreamWriter sr = new System.IO.StreamWriter(tempfile, false, System.Text.Encoding.Default);
 sr.Write(IndexContentResult.ToString());
 sr.Close();
2、用模板替换:
 template.htm  //模板文件
 <html>
 <head>
 <title>$title$</title>
 </head>
 <body>
 $body$
 </body>
 </html>
 
 .cs代码文件
 string title = "生成的网页标题";
 string body = "生成的网页内容"; 
 string filename = Server.MapPath("~/") + "frame_a/index.htm"; 
 System.IO.StreamReader srm = new System.IO.StreamReader(filename,System.Text.Encoding.Default);    
 string mb = srm.ReadToEnd();
 srm.Close();
 string tempfile = Server.MapPath("~/") + "index.htm";
 StreamWriter sr = new System.IO.StreamWriter(tempfile, false, System.Text.Encoding.Default);
 mb = mb.Replace("$title$", title);
 mb = mb.Replace("$body$", body);
 sr.Write(mb);
 sr.Close();


相关文档:

asp.net 获取当前URL的正确方法

HttpContext.Current.Request.Url.ToString() 并不可靠。
如果当前URL为
http://localhost/search.aspx?user=http://csharp.xdowns.com&tag=%BC%BC%CA%F5
通过HttpContext.Current.Request.Url.ToString()获取到的却是
http://localhost/search.aspxuser=http://csharp.xdowns.com&tag=&frac14;&fra ......

学习ASP.NET中的Application、Session、Cookie

学习ASP.NET中的Application、Session、Cookie
1.Application建立的变量,在系统内部任何地方都可以访问,通常网站地访问统计可能会用的较多。如果要用到Application首先在VS2005中建立一个global.asa文件。例如我们要写一个网站访问数量的统计的话,在global.asa中先声明变量iCount。如下所示:
     ......

ASP.NET页面传值_第一篇_概述


方法
数据量
生命期
作用域
位置
Application
任意大小
整个应用程序
所有用户
服务端
Cache
任意大小
根据需要设定
所有用户
服务端
Cookie
简单数据
根据需要设定
单个用户
客户端
Session
简单数据
用户活动时间+延迟时间(20分钟)
单个用户
服务端
Web.Config
极少改变简单数据
直到改变配 ......

ASP.NET页面传值_第五篇_Application

+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
  Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{  }
void Application_Error(object sender, EventArgs ......

asp.net 打印 拒绝访问

参考 http://topic.csdn.net/t/20040510/19/3051316.html
      开始
      运行
      dcomcnfg
      组件服务一项中选择Dcom配置,找到Microsoft   excel应用程序,察看属性
      安全选项卡中,启动权限和访问权 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号