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

熱點內容
用fes處理hg離子廢水比 瀏覽:532
樹脂粉使用說明與方法 瀏覽:176
蒸餾水可以坐電瓶液嗎 瀏覽:459
什麼牌子的飲水機過濾好 瀏覽:257
往海洋排放核廢水會有什麼後果 瀏覽:822
污水留樣時間要求 瀏覽:79
蹲廁過濾漏 瀏覽:654
反滲透膜ge美國 瀏覽:850
乙醇浸提蒸餾法 瀏覽:994
沒弓怎麼打純水 瀏覽:900
雙臂焊煙凈化器怎麼樣 瀏覽:879
環氧樹脂絕緣條 瀏覽:805
凈水器電瓶如何清洗 瀏覽:293
新款凱美瑞汽油濾芯在哪裡 瀏覽:880
超純水一體機怎麼調節單位 瀏覽:605
污水用於農用灌溉的標准 瀏覽:255
增透樹脂 瀏覽:995
南京高空排放油煙凈化器多少錢 瀏覽:195
0017是什麼型樹脂 瀏覽:587
反滲透膜濾芯安裝和取出圖片 瀏覽:690