.net静態化


//  HTML  
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/text.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(); 
} 


string htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss") ".html"; 
//      
//   ,            str      
str =str.Replace("ShowArticle",strText); //     ShowArticle 
str = str.Replace("biaoti",strText); 
str = str.Replace("content",strContent); 
str = str.Replace("author",strAuthor); 
//     
try 
{ 
sw = new StreamWriter(path htmlfilename , false, code); 
sw.Write(str); 
sw.Flush(); 
} 
catch(Exception ex) 
{ 
HttpContext.Current.Response.Write(ex.Message); 
HttpContext.Current.Response.End(); 
} 
finally 
{ 
sw.Close(); 
} 
return true; 
     Conn.CS     
             :    Hover 
if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString))) 
{ 
Response.Write("    "); 
} 
else 
{ 
Response.Write("  HTML  !"); 
} 

   Text.html   

CODE: 
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<HTML> 
<HEAD> 
<title>ShowArticletitle> 
<body> 
biaoti 
<br> 
content<br> 
author 
body> 
HTML> 
biaoti 
<br> 
content<br> 
author 
body> 
HTML> 
/****************************************************************************************/ 
  1: 
/// <summary> 
///   URL     html   
/// </summary> 
/// <param name="Url">URL</param> 
/// <returns></returns> 
public static string getUrltoHtml(string Url) 
{ 
errorMsg = ""; 
try 
{ 
System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url); 
// Get the response instance. 
System.Net.WebResponse wResp =wReq.GetResponse(); 
// Read an HTTP-specific property 
//if (wResp.GetType() ==HttpWebResponse) 
//{ 
//DateTime updated =((System.Net.HttpWebResponse)wResp).LastModified; 
//} 
// Get the response stream. 
System.IO.Stream respStream = wResp.GetResponseStream(); 
// Dim reader As StreamReader = New StreamReader(respStream) 
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 ""; 
} 
                 html  ,     .html       。 
  2: 
             ,                      ; 
          、  、       ; 
            html ,             
         :http://user.qzone.qq.com/88109988/blog/1240382157
        ,      “     ”   
http://info.china.alibaba.com/news/subject/v1-s5011580.html?head=top4&Bidding=home5 
ASP.Net    HTML  
 Asp            FileSystemObject  ! 
 .Net         System.IO 
         :      !       
CODE: 
//  HTML  
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/text.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(); 
} 

string htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".html"; 
//      
//   ,            str      
str =str.Replace("ShowArticle",strText); //     ShowArticle 
str = str.Replace("biaoti",strText); 
str = str.Replace("content",strContent); 
str = str.Replace("author",strAuthor); 
//     
try 
{ 
sw = new StreamWriter(path + htmlfilename , false, code); 
sw.Write(str); 
sw.Flush(); 
} 
catch(Exception ex) 
{ 
HttpContext.Current.Response.Write(ex.Message); 
HttpContext.Current.Response.End(); 
} 
finally 
{ 
sw.Close(); 
} 
return true; 
     Conn.CS     
             :    Hover 
if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString))) 
{ 
Response.Write("    "); 
} 
else 
{ 
Response.Write("  HTML  !"); 
} 

   Text.html   
CODE: 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<HTML> 
<HEAD> 
<title>ShowArticle</title> 
<body> 
biaoti 
<br> 
content<br> 
author 
</body> 
</HTML> 
biaoti 
<br> 
content<br> 
author 
</body> 
</HTML> 
                   html  !                   HTML   ,              ,     HTML   
  3: 
           (SJ) 
                      ,          ,        
<script> 
var oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
oXmlHttp.open("GET","http://www.163.com", false); 
oXmlHttp.send() 
var oStream = new ActiveXObject("ADODB.Stream"); 
if(oStream == null) 
alert("       ADODB.Stream.") 
else 
{ 
oStream.Type=1; 
oStream.Mode=3; 
oStream.Open() ; 
oStream.Write(oXmlHttp.responseBody); 
oStream.Position= 0; 
oStream.Type= 2; 
oStream.Charset="gb2312"; 
var result= oStream.ReadText(); 
oStream.Close(); 
oStream = null; 
var aa = window.open("","") 
document.write(result); 
aa.document.write(result); 
} 
</script> 
  4: csdn  。 xml    ,  XSL       。 
  xml     ,  xsl           。    xsl                  。              。    .net xml      。 
  :                  。 
  :         ,    。 
  5: 
   
  1.    Dw-Mx       html     ,                ( $htmlformat$),                ,           ,            ,           ,               。 
2.          Html  ,    HtmlTextWriter   html  。 
   
  1.            ,    js     , js     document.write()                ,     。 
  2.   html    MS Windows2000 Index Server          ,  asp.net   DataTable         。 Win2000 Index      xml     。           Index      ,            。 
  3.         ,       html     aspx           。 
     
     :         ,      ,      html  。    。          html      ,        ,         ,           。 
                
       
  1.  (template.htm)html     
  <html> 
  <head> 
  <title></title> 
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
  </head> 
  <body > 
  <table $htmlformat[0] height="100%" border="0" width="100%" cellpadding="10" cellspacing="0" bgcolor="#eeeeee" style="border:1px solid #000000"> 
  <tr> 
  <td width="100%" valign="middle" align="left"> 
  <span style="color: $htmlformat[1];font-size: $htmlformat[2]">$htmlformat[3]</span> 
  </td> 
  </tr> 
  </table> 
  </body> 
  </html> 
  2.asp.net  : 
  //--------------------- html     stringbuilder   ---- 
  string[] format=new string[4];//   htmlyem          
  StringBuilder htmltext=new StringBuilder(); 
  try 
  { 
   using (StreamReader sr = new StreamReader("             ")) 
   { 
  String line; 
  while ((line = sr.ReadLine()) != null) 
  { 
   htmltext.Append(line); 
  } 
  sr.Close(); 
   } 
  } 
  catch 
  { 
   Response.Write("<Script>alert('      ')</Script>"); 
  } 
  //---------------------       ------------ 
  format[0]="background="bg.jpg"";//     
  format[1]= "#990099";//     
  format[2]="150px";//     
  format[3]= "<marquee>     html  </marquee>";//     
  //----------  htm            
  for(int i=0;i<4;i++) 
  { 
   htmltext.Replace("$htmlformat["+i+"]",format); 
  } 
  //----------  htm  ------------------―― 
  try 
  { 
   using(StreamWriter sw=new StreamWriter("        ",false,System.Text.Encoding.GetEncoding("GB2312"))) 
  { 
   sw.WriteLine(htmltext); 
   sw.Flush(); 
   sw.Close(); 
  } 
  } 
  catch 
  { 
  Response.Write ("The file could not be wirte:"); 
  } 
     
             html  。          ,                  。 
C#             
  : C#&.NET   |     :   asp.net, c#, it, sql, web2.0,   ,    
     
using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using System.Data.SqlClient; 
using System.IO; 
using System.Text; 
public partial class Default4 : System.Web.UI.Page 
{ 
     protected void Page_Load(object sender, EventArgs e) 
     {     //     
         StreamWriter sw = null; 
         string htmlfilename; 
         string path = HttpContext.Current.Server.MapPath("html/"); 
         //               
     
         int     onepage=10; 
         string ConnectionString = "     "; 
         SqlConnection     myConnection     =     new     SqlConnection(ConnectionString);   
         string     sSelect     =     "SELECT     count(*)     as     pcount     from       ";   
         SqlCommand     cmd     =     new     SqlCommand(sSelect,myConnection);   
         myConnection.Open();   
         SqlDataReader     Dr     =     cmd.ExecuteReader();   
         Dr.Read();   
           int     Count=int.Parse(Dr["pcount"].ToString());   
     
           int     allpages=Count/onepage;   
     
           for     (int     i     =     0;i<allpages;     i++)   
           {   
     
     
     
         htmlfilename     =     "index_"+""+i+""+".html";   
     
           int     start     =     i     *     onepage;   
     
           int     nextpage=i+1;   
           int     perpage=i-1;   
     
           if     (nextpage==allpages)   
           {   
                 nextpage=i;   
           }   
                       
           if     (perpage==-1)   
           {   
               perpage=0;   
     
           }   
     
     
   //           
   try   
   {   
     
     
   SqlConnection     gConnection     =     new     SqlConnection(ConnectionString);   
   gConnection.Open();   
   string     vQuery     =     "SELECT     TOP     "+onepage+"     *     FROM            WHERE     (ID NOT IN (SELECT TOP "+start+" Id FROM    ORDER BY id))     ORDER     BY     ID";   
   SqlDataAdapter     vmd     =     new     SqlDataAdapter(vQuery,gConnection);   
   DataSet     ds=new     DataSet();     
   vmd.Fill(ds,"table1");     
   DataTable     dt=ds.Tables["table1"];     

     
     
   sw     =     new     StreamWriter(path     +     htmlfilename     ,     false,     Encoding.GetEncoding("GB2312"));   
   foreach(DataRow     dr     in     dt.Rows)     
   {   
   sw.WriteLine(""+dr["   "].ToString()+dr["   "]+"<br>");   
   }   
     
   sw.WriteLine("<a     href="+"index_"+""+perpage+""+".html"+">   </a>");   
   sw.WriteLine("<a     href="+"index_"+""+nextpage+""+".html"+">   </a>");   
   sw.Flush();   
   }   
   catch(Exception     ex)   
   {   
   HttpContext.Current.Response.Write(ex.Message);   
   HttpContext.Current.Response.End();   
   }   
   finally   
   {   
   sw.Close();   
   }   
   }