日期:2014-05-19  浏览次数:20461 次

怎样把asp.net的页面静态化?
请问,怎样把一些asp.net的页面静态化?能详细说以下思路吗?最好能举个例子,十分感谢!!

------解决方案--------------------
不解题意。关注帮顶下。
------解决方案--------------------
输出成 html 文件
------解决方案--------------------
把一些标签替换 然后重写一个Html文件。
用Replace方法。
------解决方案--------------------
你可以看看这个 http://www.webfort.cn,是ASP.NET做的纯静态网站
------解决方案--------------------
建立个模板页
生成时候
string title = txtTitle.Text.Trim();
string excerpt = txtFrom.Text.Trim()== " "? "未知 ":txtFrom.Text.Trim();
string author = txtAuthor.Text.Trim()== " "? "未知 ":txtAuthor.Text.Trim();
string content = txtContent.Text;
DateTime now = DateTime.Now;
string date = now.Date.ToString( "yyyy-MM-dd ");
FileStream fs = new FileStream(Server.MapPath( "news_model.aspx "),FileMode.Open,FileAccess.Read);
byte[] model = new byte[(int)fs.Length];
fs.Read(model,0,(int)fs.Length);
fs.Close();
string getModel = System.Text.Encoding.GetEncoding( "gb2312 ").GetString(model);
getModel = getModel.Replace( "[新闻标题] ",title);
getModel = getModel.Replace( "[发布日期] ",date);
getModel = getModel.Replace( "[作者] ",author);
getModel = getModel.Replace( "[摘录] ",excerpt);
getModel = getModel.Replace( "[新闻内容] ",SW.WEBLibrary.UBB2HTML.Text_UBB2HTML(content,true));

int type = int.Parse(newsType.SelectedValue);

string htmlPath = Server.MapPath( "../newsinfo/ ")+now.ToString( "yyyyMMddHHmmss ")+ ".aspx ";
string url = "newsinfo/ " + now.ToString( "yyyyMMddHHmmss ")+ ".aspx ";

Common.IO_CreatTextFile(htmlPath,getModel,false);

string upSql = "insert into news (title,content,author,excerpt,[time],type,url) values( ' "+ title + " ', ' "+ content + " ', ' "+ author + " ', ' "+
excerpt + " ', ' "+ now + " ', "+ type + ", ' "+ url + " ') ";
SqlConnection conn = new SqlConnection(connString);
SqlCommand comm = new SqlCommand(upSql,conn);
conn.Open();
try
{
comm.ExecuteNonQuery();
conn.Close();
Page.RegisterStartupScript( "msg ", " <script> alert( '添加新闻成功! ') </script> ");
}
catch(Exception err)
{
Page.RegisterStartupScript( "msg ", " <script> alert( ' "+ err.ToString() + " ') </script> ");
}
finally
{
conn.Close();
}

------解决方案--------------------

------解决方案--------------------