——此文章摘自《ASP
NET网络数据库开发实例精解》定价
¥
特价
¥
详细>>http://track
linktech
cn/?m_id=dangdang&a_id=A
&l=
&l_type
=
width=
height=
border=
nosave>
由于页面MyPassportaspx使用了NET Passport验证因此需要在该页面中引入名字空间SystemWebSecurity和SystemSecurityPrincipal等引入名字空间的程序代码如下
using SystemSecurity;
using SystemSecurityPrincipal;
using SystemWebSecurity;
using SystemSecurityPolicy;
页面MyPassportaspx使用函数UserLogin()验证用户是否登录如果用户已经登录网站或应用程序则显示相应操作否则在页面MyPassportaspx显示Passport验证登录入口函数UserLogin()的程序代码如下
private void UserLogin()
{ //使用Passport验证的身份ID
PassportIdentity pIdent = (PassportIdentity)ContextUserIdentity;
if(pIdentIsAuthenticated == true)
{ //显示用户登录成功信息
ResponseWrite(用户登录成功!!!);
ResponseWrite(<br> + 用户ID为 + pIdentHexPUID);
}
else
{ //显示用户登录入口
ResponseWrite(用户还没有登录请单击下面的登录按钮);
ResponseWrite(
pIdentLogoTag(nulltruenullfalsenullfalse));
}
}
运行效果
设置页面MyPassportaspx为应用程序的起始页面按F键运行出现如图所示的初始界面
http://developcsaicn/dotnet_ASP/images/jpg>
图 页面MyPassportaspx的初始界面
right>[http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] []