易截截图软件、单文件、免安装、纯绿色、仅160KB

重置ASP.NET membership加密后的密码

这里我只摘取了原文的Code以供潜心研究.using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Web.Security;
using System.Data;
public partial class ResetPassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
// 重置
protected void btnReset_Click(object sender, EventArgs e)
{
string connStr = WebConfigurationManager.ConnectionStrings["conn"].ToString();
string username = txtUserName.Text.Trim();
if (username.Length==0)
{
Response.Write("请输入用户名!");
return;
}
//=== 产生加密用的密码密钥 ===
string salt = GenerateSalt();
//=== 将明码密码加密(此时密码为"P@ssw0rd" 当然也可随机数生成) ===
string password = EncryptToHashString("123456", salt, "SHA1");
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
//=== 在此我们呼叫 Membership 提供者 数据库里的预存程序来重置密码 ===
SqlCommand cmd = new SqlCommand("aspnet_Membership_SetPassword", conn);
cmd.CommandType = CommandType.StoredProcedure;
//=== 目前使用 Membership 提供者的 web 应用程序名称 ===
cmd.Parameters.Add(new SqlParameter("@ApplicationName", Membership.ApplicationName));
//=== 要重置密码的用户账号 ===
cmd.Parameters.Add(new SqlParameter("@UserName", username));
//=== 加密过的密码 ===
cmd.Parameters.Add(new SqlParameter("@NewPassword", password));
//=== 密码加密密钥(一定和使用加密密码的密钥一样,不要再重新产生) ===
cmd.Parameters.Add(new SqlParameter("@PasswordSalt", salt));
//=== 重置密码的时间 ===
cmd.Parameters.Add(new SqlParameter("@CurrentTimeUtc", DateTime.Now));
//=== 密码加密的格式(此时是Hash1,注意传入参数


相关文档:

ASP.NET application and page life cycle 2

http://www.codeproject.com/KB/aspnet/ASPDOTNETPageLifecycle.aspx?msg=3443071#xx3443071xx
ASP.NET application and page life cycle
Introduction
The Two step process
Creation of ASP.NET environment
Process request using MHPM events fired
In What event we should do what?
A sample code for demons ......

asp.net图片验证码

asp.net系统,在登录或注册时常提供数字或字符混合的验证码,这里介绍如何操作。
1,Default 页面
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  & ......

C#(ASP.Net)获取当前路径的方法集合

//获取当前进程的完整路径,包含文件名(进程名)。  
string str = this.GetType().Assembly.Location;  
result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)  
//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。  
s ......

ASP.NET各种跨页面传值方法技巧总结

ASP.NET各种跨页面传值方法技巧总结
 
1.使用QueryString变量
    QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。下面是一个例子: ......

Asp.Net性能优化

(一).选择会话状态存储方式
    在Webconfig文件配置:
    <sessionState mode="???" stateConnectionString="tcpip=127.0.0.1:42424"
         sqlConnectionString="data source=127.0.0.1;Trusted_Connection=y ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号