MD5加密:
string aa=FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5"); SHA1加密:
string bb=FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");
sha512 : SHA512加密:
SHA512 sha = new SHA512Managed();
byte[] inArray = sha.ComputeHash(Encoding.Default.GetBytes(xf6987a1745781d6f));
sha.Clear();
string cc=Convert.ToBase64String(inArray); 序列化:
系列化对象成一个文件
yzInfo yz = new yzInfo();
yz.userName = "wangzhiyong";
yz.passWord = "123456";
BinaryFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream("MyFile.db", FileMode.Create,
FileAccess.Write, FileShare.None);
formatter.Serialize(stream, yz);
stream.Close();
反系列化文件成一个对象
BinaryFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream("MyFile.db", FileMode.Open,
FileAccess.Read, FileShare.Read);
yzInfo obj = (yzInfo)formatter.Deserialize(stream);
stream.Close();
Response.Write(obj.userName);
WebConfig配置表单验证:
把你不需要验证的所有页放在一个目录下面,但是不用在那个目录下面的WEB.CONFG中对FROMS验证模式进行设置。只要在最上层的wepconfig中统一设置就可以了.比如下面的例子:
一、设置所有页面都需要验证
<system web>
<authentication mode="Forms">
<forms loginUrl = "Lonin.aspx" name = ".ASPXFORMSAUTH"/>
</authentication>
</system web>
二、再特别设置对某个目录下的页面不需要验证(NoAuto为不需要验证的页面所在的目录)
<location path="NoAuto">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>