Using System; Using System. Data; Using System. configuration; 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. Text. regularexpressions; Using System. IO;/// <Summary> /// Summary of createhtml /// Asp.net generates HTML static pages /// Call method: /// New createhtml (). nei_create ("http: // localhost: 4032/new5mdn/default. aspx", "default.htm "); /// </Summary> Public class Createhtml : System. Web. UI. Page { Public Createhtml (){}/// <Summary> /// Generate a static page under this project /// </Summary> /// <Param name = "strurl"> Request URL </Param> /// <Param name = "strrelpath"> The created path and file name. The path is relative path. </Param> /// <returns> </returns> Public bool Nei_create ( String Strurl, String Strrelpath ){ String Strfilepage; strfilepage = Httpcontext . Current. server. mappath (strfilepage ); Streamwriter Sw = Null ; // Obtain the static html of aspx Try { If ( File . Exists (strfilepage )){ File . Delete (strfilepage);} Sw = New Streamwriter (Strfilepage, False , System. Text. Encoding . Getencoding ("Gb2312" ); System. net. Webrequest Wreq = system. net. Webrequest . Create (strurl); system. net. Webresponse Wresp = wreq. getrequeststream (); system. Io. Stream Respstream = wresp. getresponsestream (); system. Io. Streamreader Reader = New Streamreader (Respstream, system. Text. Encoding . Getencoding ( "Gb2312" ));String Strtemp = reader. readtoend (); RegEx R1 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ eventtarget \ ". */>" , Regexoptions . Ignorecase ); RegEx R2 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ eventargument \ ". */>" , Regexoptions . Ignorecase );RegEx R3 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ viewstate \ ". */>" , Regexoptions . Ignorecase ); RegEx R4 = New RegEx ( "<Form. * id = \" form1 \ ">" , Regexoptions . Ignorecase ); RegEx R5 = New RegEx ( "</Form>" ); RegEx R6 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ eventvalidation \ ". */>" , Regexoptions . Ignorecase); strtemp = r1.replace (strtemp, "" ); Strtemp = r2.replace (strtemp, "" ); Strtemp = r3.replace (strtemp, "" ); Strtemp = r4.replace (strtemp, "" ); Strtemp = r5.replace (strtemp, "" ); Strtemp = r6.replace (strtemp, "" ); Sw. Write (strtemp );} Catch ( Exception Ex ){ Httpcontext . Current. response. Write (ex. Message ); Httpcontext . Current. response. End (); Return false ; // Generate an error } Finally {Sw. Flush (); Sw. Close (); Sw =Null ;}} /// <Summary> /// Generate a static page, which is not in this project /// </Summary> /// <Param name = "strurl"> Request URL </Param> /// <Param name = "strrelpath"> Path and file name. The path is an absolute path. </Param> Public bool Wai_create ( String Strurl, String Strrelpath, String Filename ){String Strfilepage; strfilepage = strrelpath + "\\" + Filename; Streamwriter Sw = Null ; // Obtain the static html of aspx Try { If (! Directory . Exists (strrelpath )){ Directory . Createdirectory (strrelpath );} If ( File . Exists (strfilepage )){ File . Delete (strfilepage);} Sw = New Streamwriter (Strfilepage, False , System. Text. Encoding . Getencoding ( "Gb2312" ); System. net. Webrequest Wreq = system. net. Webrequest . Create (strurl); 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" )); String Strtemp = reader. readtoend (); RegEx R1 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ eventtarget \ ". */>" ,Regexoptions . Ignorecase ); RegEx R2 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ eventargument \ ". */>" , Regexoptions . Ignorecase ); RegEx R3 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ viewstate \ ". */>" , Regexoptions . Ignorecase );RegEx R4 = New RegEx ( "<Form. * id = \" form1 \ ">" , Regexoptions . Ignorecase ); RegEx R5 = New RegEx ( "</Form>" ); RegEx R6 = New RegEx ( "<Input type = \" Hidden \ "name = \" _ eventvalidation \ ". */>" , Regexoptions . Ignorecase); strtemp = r1.replace (strtemp, "" ); Strtemp = r2.replace (strtemp, "" ); Strtemp = r3.replace (strtemp, "" ); Strtemp = r4.replace (strtemp, "" ); Strtemp = r5.replace (strtemp, "" ); Strtemp = r6.replace (strtemp, "" ); Sw. Write (strtemp );} Catch ( Exception Ex ){Httpcontext . Current. response. Write (ex. Message ); Httpcontext . Current. response. End (); Return false ; // Generate an error } Finally {Sw. Flush (); Sw. Close (); Sw = Null ;} Return true ;} Public void Filepicdelete ( String Path) {system. Io. Fileinfo File =New System. Io. Fileinfo (); If (File. exists) file. Delete ();}}