Sql注入问题

| 我有HttpHandler页面,该页面用来做一些使用DB的工作。我需要能够防止人们访问此文件,并确保信息的路径是我的网站,而不是另一个使用Processrequest实现此目的的网页。
    public void ProcessRequest (HttpContext context) {


    if (context.Request.Url.Authority.ToString() != HttpContext.Current.Request.Url.Authority.ToString())
        return;
    context.Response.ContentType = \"text/plain\";
    string str = context.Request.Form[\"recordsArray[]\"].ToString();
    char[] delimiters = new char[] { \',\', \';\' };
    string[] arr = str.Split(delimiters);

    for (int i = 0; i < arr.Length; i++)
    {
         Functions.Add(new tab(arr[i])); // insert records into table Tabs => int id, string name           
    }

}
    
已邀请:
如果要阻止人们正常访问某些资源,则可以通过身份验证来保护此资源:您可以为授权用户授予用户名/密码,以使他们与未经授权的用户区分开。 可以伪造一个HTTP请求,使它看起来就像来自您的域一样,而实际上却不是。因此,唯一的方法是使用一些秘密。     
您也可以为您处理SQL注入。 Linq到sql:http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt- asp-linqdatasource-gt-control.aspx 或者更简单一些,您可以使用SQL参数(Linq to SQL使用的是): (简短指南):http://www.sharpdeveloper.net/content/archive/2007/05/25/creating-sqlparameters-best-practices.aspx 或在这里 http://msdn.microsoft.com/zh-CN/library/system.data.sqlclient.sqlparameter.aspx 我知道这不是专门针对您的解决方案,但希望对您有所帮助。     

要回复问题请先登录注册