对于客户方
在Internet Explorer中
右键单击浏览器 - >查看源代码
在Firefox中
右键单击浏览器 - >查看页面源
对于服务器端
您可以覆盖页面的render方法以捕获服务器端的HTML源代码.
protected override void Render(HtmlTextWriter writer)
{
// setup a TextWriter to capture the markup
TextWriter tw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(tw);
// render the markup into our surrogate TextWriter
base.Render(htw);
// get the captured markup as a string
string pageSource = tw.ToString();
// render the markup into the output stream verbatim
writer.Write(pageSource);
// remove the viewstate field from the captured markup
string viewStateRemoved = Regex.Replace(pageSource,
"<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\".*?\" />",
"", RegexOptions.IgnoreCase);
// the page source, without the viewstate field, is in viewStateRemoved
// do what you like with it
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11438 次 |
最近记录: |