zoukankan      html  css  js  c++  java
  • asp.net入門經典讀書筆記

    一、提高性能的方法:
    1.Remember that database access is relatively expensive—it
    consumes both time and resources.
    2.應用一個控件屬性多次是,最好先把屬性放到一個局部變量中
    二、處理錯誤
    1.防禦代碼
    In general, you should always check incoming parameters if the method is a public one—that is, it is
    called from outside the class. If it’s a method that isn’t accessible from outside of the class (private or
    556
    Chapter 15
    protected), then this is less important because you’re probably supplying those parameters yourself,
    although this doesn’t necessarily mean the parameters will be correct—you might get the values from
    elsewhere before passing them into the method.

    2.The solution to SQL injection is to use parameters, because these automatically prevent this type of attack.
    If you’re using stored procedures, which you should be, then parameters are required for passing information
    into the procedure, but when you’re building SQL dynamically, you can still use parameters. So if
    you were running a SqlCommand, you could do this:
    string SQL = “SELECT * FROM Employee WHERE LastName=@LastName”
    SqlCommand cmd = new SqlCommand(SQL, conn);
    cmd.Parameters.Append(“@LastName”, SqlDbType.VarChar, 50);
    cmd.Paramaters[“@LastName”].Value = LastName.Text;
    Here @LastName is the parameter name, and because the value is assigned via the parameter, no SQL
    injection can take place. This is because ADO.NET protects against SQL injection attacks when using
    parameters—the values passed into parameters are checked for specific content that would signify an
    attack.

  • 相关阅读:
    询问给定图中树的棵数
    题目1365:贝多芬第九交响曲
    题目1463:招聘会
    九度 题目1395:爱钱的胡老板
    HDU 4666 Hyperspace && POJ 2926 Requirements
    九度 题目1493:公约数
    九度 题目1523:从上往下打印二叉树 题目1521:二叉树的镜像
    iOS CoreBluetooth 教程 蓝牙
    点击推送,跳转到查看推送消息的页面
    学习ios蓝牙技术,仿写lightblue
  • 原文地址:https://www.cnblogs.com/anchenjie007/p/1017287.html
Copyright © 2011-2022 走看看