導航:首頁 > 凈水問答 > net訪問過濾路徑

net訪問過濾路徑

發布時間:2023-08-26 09:17:33

⑴ asp.net如何過濾掉html代碼

Asp.net中如何過濾html,js,css代碼
以下為引用的內容:

#region/// 過濾html,js,css代碼
/// <summary>
/// 過濾html,js,css代碼
/// </summary>
/// <param name="html">參數傳入</param>
/// <returns></returns>
public static string CheckStr(string html)
{
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<script[\s\S]+</script *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[\s\S]*script *:", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" no[\s\S]*=", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[\s\S]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[\s\S]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"\<img[^\>]+\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"</p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"<p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = regex1.Replace(html, ""); //過濾<script></script>標記
html = regex2.Replace(html, ""); //過濾href=javascript: (<A>) 屬性
html = regex3.Replace(html, " _disibledevent="); //過濾其它控制項的on...事件
html = regex4.Replace(html, ""); //過濾iframe
html = regex5.Replace(html, ""); //過濾frameset
html = regex6.Replace(html, ""); //過濾frameset
html = regex7.Replace(html, ""); //過濾frameset
html = regex8.Replace(html, ""); //過濾frameset
html = regex9.Replace(html, "");
html = html.Replace(" ", "");
html = html.Replace("</strong>", "");
html = html.Replace("<strong>", "");
return html;
}
#endregion
#region /// 過濾p /p代碼
/// <summary>
/// 過濾p /p代碼
/// </summary>
/// <param name="html">參數傳入</param>
/// <returns></returns>
public static string InputStr(string html)
{
html = html.Replace(@"\<img[^\>]+\>", "");
html = html.Replace(@"<p>", "");
html = html.Replace(@"</p>", "");
return html;
}
#endregion

閱讀全文

與net訪問過濾路徑相關的資料

熱點內容
凈水器反滲透口為什麼在滴水 瀏覽:836
2012年污水廠安全生產試題 瀏覽:632
制備離子交換樹脂的單體是 瀏覽:835
污水的處理法有哪些 瀏覽:802
生活污水產生多少污泥 瀏覽:486
環氧樹脂發光字價格 瀏覽:369
機械加工含油廢水怎麼處理 瀏覽:818
豬場污水處理平均多少錢一噸 瀏覽:176
養殖廢水cod排放標準是多少 瀏覽:729
過慮壺的過濾芯在哪裡買好 瀏覽:239
D型大孔吸附樹脂的密度 瀏覽:363
鍍鋅廢水ph多少 瀏覽:153
超濾機過濾好後氣泡 瀏覽:694
含亞鐵廢水是什麼顏色 瀏覽:893
物業清理污水井的溫馨提示 瀏覽:704
硫化污水怎麼處理 瀏覽:216
自然水體怎麼做污水指示 瀏覽:552
hepa過濾網怎麼做的 瀏覽:677
新換ro膜 瀏覽:926
永寧縣污水處理廠安全事故 瀏覽:711