asp.net 生成静态时的过滤viewstate的实现方法

复制代码 代码如下:
public static string GetSourceTextByUrl(string url)
{
WebRequest request = WebRequest.Create(url);
request.Timeout = 200000;//20秒超时
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream);
string tempstr = sr.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);
//过滤<form>代码
Regex r4 = new Regex("<form name=/"ASPNETForm/".*id=/"ASPNETForm/">", RegexOptions.IgnoreCase);
Regex r5 = new Regex("</form>");
tempstr = r1.Replace(tempstr, "");
tempstr = r2.Replace(tempstr, "");
tempstr = r3.Replace(tempstr, "");
tempstr = r4.Replace(tempstr, "");
tempstr = r5.Replace(tempstr, "");

return tempstr;
}

AspNet技术asp.net 生成静态时的过滤viewstate的实现方法,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。