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

熱點內容
提升泵啟動流程 瀏覽:437
中國承接國外污水處理項目 瀏覽:527
壘污水井注意什麼 瀏覽:195
ats高效過濾器 瀏覽:296
凈化器吸力不夠怎麼辦 瀏覽:215
離子交換色譜法的陰離子滯留順序 瀏覽:792
凈水器不出水了怎麼辦 瀏覽:951
環氧樹脂地坪漆配合比 瀏覽:143
離子交換時濃度多少 瀏覽:443
反滲透膜一級兩段什麼意思 瀏覽:947
垃圾電廠水處理用的葯劑 瀏覽:572
為什麼凈水器沒有排污水 瀏覽:862
加濕器如何連接凈水器 瀏覽:721
膠體半透膜視頻 瀏覽:243
聚酯樹脂上漲 瀏覽:627
污水菌種載體有哪些 瀏覽:158
從手機里提煉黃金廢水怎麼辦 瀏覽:690
1693b50g凈水器怎麼樣 瀏覽:255
5月13日哈爾濱回肇東用隔離嗎 瀏覽:35
襯環氧樹脂的方法 瀏覽:128