SoFunction
Updated on 2025-03-04

Implementation method of filtering viewstate when generating static


public static string GetSourceTextByUrl(string url)
{
WebRequest request = (url);
= 200000;//20 seconds timeout
WebResponse response = ();
Stream resStream = ();
StreamReader sr = new StreamReader(resStream);
string tempstr = ();

Regex r1 = new Regex("<input type=\"hidden\" name=\"__EVENTTARGET\".*/>", );
Regex r2 = new Regex("<input type=\"hidden\" name=\"__EVENTARGUMENT\".*/>", );
Regex r3 = new Regex("<input type=\"hidden\" name=\"__VIEWSTATE\".*/>", );
//Filter <form> code
Regex r4 = new Regex("<form name=\"aspnetForm\".*id=\"aspnetForm\">", );
Regex r5 = new Regex("</form>");
tempstr = (tempstr, "");
tempstr = (tempstr, "");
tempstr = (tempstr, "");
tempstr = (tempstr, "");
tempstr = (tempstr, "");

return tempstr;
}