Rewrite the render method to remove viewstate and improve website performance.
System. Io. stringwriter html = New System. Io. stringwriter (); system. Web. UI. htmltextwriter TW = New System. Web. UI. htmltextwriter (HTML ); Base . Render (TW ); String Temp = Html. tostring (); String S1 = String . Empty, S2 = String . Empty, S3 =String . Empty, S4 = String . Empty, S5 = String . Empty, S6 = String . Empty; Int I = 0 ; Int J = 0 ; I = Temp. indexof ( " <Form " ); If (I> 0 ) {J = Temp. indexof ( " > " , I); S1 = Temp. substring ( 0 , I); S2 = Temp. substring (J + 1 , Temp. Length-j- 1 );} I = S2.indexof (" <Input type = \ "Hidden \" name = \ "_ viewstate \" id = \ "_ viewstate \" " ); If (I> 0 ) {J = S2.indexof ( " > " , I); S3 = S2.substring ( 0 , I); S4 = S2.substring (J +1 , S2.length-j- 1 );} I = S4.indexof ( " <Input type = \ "Hidden \" name = \ "_ eventvalidation \" id = \ "_ eventvalidation \" " ); If (I> 0 ) {J = S4.indexof ( " > " , I); S5 = S4.substring ( 0 , I); S6 = S4.substring (J + 1 , S4.length-j- 1 ); Temp = S1 + S3 + S5 + S6 ;} Else {Temp = S1 + S3 + S4;} temp = Temp. Replace ( " </Form> " , "" ); Temp = Temp. Replace ( " \ R \ n " , "" ); TW. Close (); response. Write (temp );
Reference: http://www.cnblogs.com/cmsdn/archive/2011/12/12/2285137.html