在网站优化工作中,静态化页面对SEO非常友好:
1、网页打开速度快,因为是直接读取文件;
2、有利于搜索引擎的抓取收录;
3、静态网页相对比较稳定,对服务器友好;
4、一些面对数据库的攻击比如SQL注入攻击,在面对静态网页的时候常常难以从地址入手。
动态页面如aspx,php等以html,shtml等形式表示可用模板或urlrewriter静态化
public static bool WriteFile(string strText,string strContent,string strAuthor)
{
string path = HttpContext.Current.Server.MapPath("/news/")
Encoding code = Encoding.GetEncoding("gb2312")
string temp = HttpContext.Current.Server.MapPath("/news/template.html")
StreamReader sr=null
StreamWriter sw=null
string str=""
try
{
sr = new StreamReader(temp, code)
str = sr.ReadToEnd()
}
catch(Exception exp)
{
HttpContext.Current.Response.Write(exp.Message)
HttpContext.Current.Response.End()
sr.Close()
}
public static string getUrltoHtml(string Url)
{
errorMsg = ""
try
{
System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url)
System.Net.WebResponse wResp =wReq.GetResponse()
System.IO.Stream respStream = wResp.GetResponseStream()
System.IO.StreamReader reader = new System.IO.StreamReader(respStream, System.Text.Encoding.GetEncoding("gb2312"))
return reader.ReadToEnd()
}
catch(System.Exception ex)
{
errorMsg = ex.Message
}
return ""
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)