你现在的位置 :
教程
=>
软件开发
=>
VC++
=>编程技巧 Dot.net的安全机制
文章搜索
编程技巧 Dot.net的安全机制
时间: 2006-09-15 来自:CSDN
使用时添加以下引用单元
其中OleDb使用Access,sqlserver使用SqlClient
using System.Web.Security;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Configuration;
在web.config中配制authebtication
<authentication mode="Forms">
<forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
创建login.aspx页面
计算MD5:
string strInputPass = System.Web.Security.FormsAuthentication
.HashPasswordForStoringInConfigFile("manager","md5");
Response.Write(strInputPass); //从数据库中读出计算
if ((UserEmail.Text == "qianbo") && (UserPass.Text== strInputPass))
{
FormsAuthentication.RedirectFromLoginPage(UserEmail.Text, false);
}
else
{
Msg.Text = "Invalid Credentials: Please try again";
}
private void Page_Load(object sender, System.EventArgs e)
{
WelCome.Text = "Hello, " + User.Identity.Name;// 在此处放置用户代码以初始化页面
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
登出:
private void Button1_Click(object sender, System.EventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect("login.aspx");
}
相关文章
·
VisualC++编程窃取QQ密码
·
基于VisualC++6.0的Add-in编程实例
·
深入浅出VC++串口编程之基于Win32A
·
VisualC++编程隐藏计算机中的鼠标
·
通过COM技术实现WindowsShell编程
·
VisualC++6.0编程实现打印功能
·
WindowsGDI和GDI+编程实例剖析
·
VC++动态链接库(DLL)编程深入浅出
·
VisualC++编程技巧小结
·
VisualC++中DDB与DIB位图编程全
标题
正文
·如何让您的网站流量大增?
热点排行
最新文章
用VC实现动态改变Win
三种常见中文内码的转换
DirectShow入门之构建
利用VisualC++制作应用
VC中利用WinAPI实
用VC获取其它程序的命
DirectShow入门之动态
VisualC++编程窃取QQ
用VisualC++设计QQ群
VisualC++6.0实现多层
VC++6.0在灰度数字图像
用VC实现对超长数据库