易截截图软件、单文件、免安装、纯绿色、仅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 Ajax Library...

 有很久一段时间我的BLOG上没有出现AJAX相关讯息了,主要当然是因为绝大部分的重心都放到了Silverlight身上(可预期的未来应该也会是如此)。
但由于工作上的需要,最近还是回头看了一下即将推出的ASP.NET Ajax Library...,顺便找了一下网络上的讯息,看这个态势我猜想应该不少ASP.NET开发人员忽略掉了这个其实已经bet ......

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清空页面所有textbox的几种方法总结

Asp.Net清空页面所有textbox的几种方法总结
 在Asp.Net中清空所有textbox有好几种方法,本文提供几种,供大家参考!
 
foreach( Control childControl in this.Controls )  
{  
if( childControl is TextBox )  
((TextBox)childControl).Text = "";  
}&n ......

ASP.net弹出消息对话框的方法

我们在ASP.NET程序的开发过程中,常常需要向用户给出提示信息,比如是否“操作成功”,“确定”还是“取消”操作。
   
    (1) 点击页面上的按钮,弹出一个对话框提示是“确定”还是“取消”操作,我们采用在按钮中添加属性来完成:
......

ASP.NET与JavaScript交互

1.asp.net呼叫js
view
plain
copy
to clipboard
print
?
Response.Write("<mce:script language=javascript><!--  
");  
Response.Write("alert('欢迎您 ');"
 );  
Response.Write("location.href='login.aspx';"
)& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号