您的位置:首页 > 其它

NET移植案例学习:建造Web站点(6)

2008-05-01 04:29 253 查看
document.write(baiduCproIFrame());--> 图3Config.Web文件

<?xmlversion="1.0"encoding="utf-8"?>

<configuration>

 <!--SECURITY

Thissectionsetsthesecuritypoliciesoftheapplication.

Possiblemodesare"Windows","Cookie",

"Passport"and"None"

 -->

 <!--UseCookieAuthenticationforexternalusers-->

 <security>

<authenticationmode="Cookie">

 <cookiecookie=".PRODAUTH"loginurl="https://

 beta.visualstudio.NET/Login.aspx"

decryptionkey="autogenerate">

<credentialspasswordformat="Clear"/>

 </cookie>

</authentication>

<authorization>

 <allowusers="*"/>

</authorization>

 </security>

</configuration>

图4认证代码

PublicSubcmdSubmit_Click(ByValsenderAsObject,ByValeAs_

System.EventArgs)

 DimsUserIDAsString

 DimsPasswordAsString

 DimsAuthCookieAsString

 'Externaluser,takethevaluesfromtheLoginform

 sUserid=system.Convert.ToString(Me.txtUserID.Value)

 sPassword=system.Convert.ToString(Me.txtPassword.Value)

 adoRS=oBetaUser.LoginEx(sUserID,sPassword)

 IfadoRS.recordcount=1Then

'loginsuccess-getasession

adoRS=osSession.GetNewSession_

(adoRS("BetaSiteID").Value.ToString().ToInt32())

IfNotadoRSIsNothingThen

 IfadoRS.Recordcount>0Then

adoRS.movefirst()

'SettheauthenticationcookieusingtheSID

sAuthCookie=adoRS("SID").Value.ToString()

'useASP+authenticationtoauthenticatetheuser,

IfInstr(CookieAuthentication.GetRedirectUrl_

 (sAuthCookie,True),"default.aspx")>0Then

 CookieAuthentication.SetAuthCookie(sAuthCookie,True)

 Response.Redirect(system.Convert.ToString(_

oSiteUser.GlobalPath)&"Home.aspx")

Else

 CookieAuthentication.RedirectFromLoginPage(_

 sAuthCookie,True)

EndIf

 Else

'loginfailed

Response.Redirect("LoginFailed.aspx")

 EndIf

Else

 'loginfailed

 Response.Redirect("LoginFailed.aspx")

EndIf

 Else

'loginfailed

Response.Redirect("LoginFailed.aspx")

 EndIf

EndSub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: