function works perfectly. it makes source code single line. but problem is about Google Adsense ads. their locations get messed up. what might be the reason ?
programming language is c# asp.net 4.0
here the function
protected override void Render(HtmlTextWriter writer)
{
if (this.Request.Headers["X-MicrosoftAjax"] != "Delta=true")
{
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"<script[^>]*>[\w|\t|\r|\W]*?</script>");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
base.Render(hw);
string html = sb.ToString();
System.Text.RegularExpressions.MatchCollection mymatch = reg.Matches(html);
html = reg.Replace(html, string.Empty);
reg = new System.Text.RegularExpressions.Regex(@"(?<=[^])\t{2,}|(?<=[>])\s{2,}(?=[<])|(?<=[>])\s{2,11}(?=[<])|(?=[\n])\s{2,}|(?=[\r])\s{2,}");
html = reg.Replace(html, string.Empty);
reg = new System.Text.RegularExpressions.Regex(@"</body>");
string str = string.Empty;
foreach (System.Text.RegularExpressions.Match match in mymatch)
{
str += match.ToString();
}
html = reg.Replace(html, str + "</body>");
writer.Write(html);
}
else
base.Render(writer);
}