C# 经典购物车流程全代码 asp.net 经典毕业设计
C# 购物车 及后台代码
C# 程序语言
一.防止SQL注入
public static bool SqlFilter2(string InText)
{ string word = "and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join|'"; if (InText == null)
return false;
foreach (string str_t in word.Split('|'))
{if ((InText.ToLower().IndexOf(str_t + " ") > -1) || (InText.ToLower().IndexOf(" " + str_t) > -1) || (InText.ToLower().IndexOf(str_t) > -1))
{ return true;//返回有}
}
}
二.MD5加密
using system.web.security
string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text,"MD5");
四..配置文件的加密与解密
数据库连接字符串
<appSettings>
<add key=”ConnectionString” value=”server=(Local);database = test; pwd=sa;uid=sa;”/> </appSettings
加密
Configurationconfig=WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section config.GetSection(”appSettings”);
if(section !=null && !section.SectionInformation.IsProtected)
{ Section.SectionInformation.ProtectSection(”RsaProtectedConfigurationProvider”); Config.Save();
}
解密
Configuration
config=WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection section =config.GetSection(“appSettings”);
If(section !=null && secion.SectionInformation.IsProtected)
{Section SectionInformation.UnprotectSection();
Config.Save();
}
五.邮件的发送和接收
Encoding encoding = Encoding.GetEncoding("GB2312");
string address = TextBox1.Text.Trim();
string biaoti = "购物网用户激活";
string content = "status.aspx?id=" + TextBox2.Text + "";