ÖØÖÃ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£¬×¢Òâ´«Èë²ÎÊý
Ïà¹ØÎĵµ£º
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 ......
/// <summary>
/// HTML½âÂë
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public string HtmlDecode(string input)
&nb ......
½ñÌìÑо¿ÁËÒ»ÏÂÔÚasp.netÏÂÓÃC#ÓïÑÔѹËõÎļþ£¬ºÍ½âѹÎļþ£¬ÔÚÍøÉϺÃÁ˺þòÅÕÒµ½Ô´´úÂ룬£¬Õæ²»ÈÝÒ×°¡£¡£¡
ÔÚ ASP.NET ÖÐÓÐÁ½¸öÀࣺDeflateStream ºÍ GZipStream ÓÃÓÚ´¦ÀíѹËõºÍ½âѹËõ£¬ÕâÁ½¸öÀà·Ö±ðʹÓõÄÊÇ DEFLATE ºÍ gzip ѹËõËã·¨£¬ÕâÁ½¸öËã·¨±»Ò»Ð©Ñ¹ËõÈí¼þÖ§³Ö£¬±ÈÈç WinRAR ¾ÍÖ§³Ö gzip¡£ÕâÁ½¸öÀàµÄÃû³Æ¿Õ¼ä¾ùΪ£ ......
Ò»¡¢·µ»Ø¶à¸öÊý¾Ý¼¯
¼ì²éÄãµÄ·ÃÎÊÊý¾Ý¿âµÄ´úÂ룬¿´ÊÇ·ñ´æÔÚ×ÅÒª·µ»Ø¶à´ÎµÄÇëÇó¡£Ã¿´ÎÍù·µ½µµÍÁËÄãµÄÓ¦ÓóÌÐòµÄÿÃëÄܹ»ÏìÓ¦ÇëÇóµÄ´ÎÊý¡£Í¨¹ýÔÚµ¥¸öÊý¾Ý¿âÇëÇóÖзµ»Ø¶à¸ö½á¹û
¼¯£¬¿ÉÒÔ¼õÉÙÓëÊý¾Ý¿âͨÐŵÄʱ¼ä£¬Ê¹ÄãµÄϵͳ¾ßÓÐÀ©Õ¹ÐÔ£¬Ò²¿ÉÒÔ¼õÉÙÊý¾Ý¿â·þÎñÆ÷ÏìÓ¦ÇëÇóµÄ¹¤×÷ ......
1. Éú³ÉaspnetµÄȨÏÞÊý¾Ý±íºÍsp£¬Ê¹ÓÃ.net 2.0µÄÃüÁîÈçÏ£º
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql -W
ʹÓÃ-W²ÎÊýµ÷³öÁ¬½ÓÊý¾Ý¿âÏòµ¼£¬¸ù¾ÝÏòµ¼Éú³ÉÊý¾Ý¿âÊý¾Ý¡£
2. ÔÚweb.config¸ü¸ÄÑéÖ¤·½Ê½²¢Ìí¼Óproviders
<configuration>
<connectionStrings>
<add name="dbConn ......