/// <summary>
/// 访问页面的基类
/// by 贾世义 2011-8-28
/// </summary>
public class BaseWWW : Page
{
#region 变量和字段
/// <summary>
/// 替代Page.Request.QueryString
/// </summary>
protected NameValueCollection QueryString;
/// <summary>
/// 重载OnLoad排除注入代码和处理
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
{
QueryString = new NameValueCollection();
//排除注入代码
for (int i = 0; i < Page.Request.QueryString.Count; i++)
{
string key = Page.Request.QueryString.Keys[i];
QueryString.Add(key, Page.Request.QueryString[key].Replace(" ", "").Replace("(", "").Replace(")", "").Replace("'", "").Replace("'", ""));
}
base.OnLoad(e);
}
}
本文详细介绍了访问页面基类的设计与实现,通过优化Request.QueryString处理方式,防止注入攻击并提升性能。
2万+

被折叠的 条评论
为什么被折叠?



