導航:首頁 > 凈水問答 > 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訪問過濾路徑相關的資料

熱點內容
凈化器油煙大怎麼辦 瀏覽:657
論文化學水處理 瀏覽:177
瑞風m5空調濾芯在哪裡視頻 瀏覽:542
四分之三的廢水流向農田怎麼翻譯 瀏覽:410
凈水機什麼牌子的濾芯 瀏覽:646
風油精過濾嘴煙中醫 瀏覽:492
陝西污水處理廠工資待遇 瀏覽:113
cto和udf濾芯什麼區別 瀏覽:318
小店區洗砂廠污水沉澱慢怎麼辦 瀏覽:846
污水處理怎麼看出硝化菌死亡 瀏覽:834
熱水機水垢如何處理 瀏覽:550
安吉爾凈水器指示燈怎麼復原 瀏覽:71
提高高吸水樹脂強度 瀏覽:731
箭牌智能馬桶噴頭除垢 瀏覽:332
污水檢查井為什麼不能磚砌 瀏覽:503
浸膜RO 瀏覽:548
飲水機水垢是什麼原因 瀏覽:374
樹脂工藝花盆的製作過程 瀏覽:325
光敏樹脂可以做uv嗎 瀏覽:211
怎麼換艾瑞澤七機油濾芯 瀏覽:654