程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> NET移植案例學習:建造Web站點(6)

NET移植案例學習:建造Web站點(6)

編輯:ASP技巧
圖3 Config.web文件

<?XML version="1.0" encoding="utf-8" ?>
<configuration>

 <!-- SECURITY 
  This section sets the security policIEs of the application.
  Possible modes are "Windows", "CookIE", 
  "Passport" and "None"
 -->

 <!-- Use CookIE Authentication for external users -->


 <security>
  <authentication mode="CookIE">
   <cookie cookIE=".PRODAUTH" loginurl="https://
     beta.visualstudio.Net/Login.ASPx" 
    decryptionkey="autogenerate">

    <credentials passWordformat="Clear" />
   </cookIE>
  </authentication>
  <authorization>
   <allow users="*" />
  </authorization>
 </security> 
</configuration>


  圖4 認證代碼

Public Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) 
 Dim sUserID As String
 Dim sPassWord As String
 Dim sAuthCookIE As String

 'External user, take the values from the Login form
 sUserid = system.Convert.ToString(Me.txtUserID.Value)
 sPassword = system.Convert.ToString(Me.txtPassWord.Value)

 adoRS = oBetaUser.LoginEx(sUserID, sPassWord)

 If adoRS.recordcount = 1 Then
  'login success - get a session
  adoRS = osSession.GetNewSession _
    (adoRS("BetaSiteID").Value.ToString().ToInt32())

  If Not adoRS Is Nothing Then
   If adoRS.Recordcount > 0 Then
    adoRS.movefirst()

    'Set the authentication cookIE using the SID
    sAuthCookIE = adoRS("SID").Value.ToString()

    'use ASP+ authentication to authenticate the user, 
    If Instr(CookIEAuthentication.GetRedirectUrl _
       (sAuthCookIE, True), "default.ASPx") > 0 Then
     CookieAuthentication.SetAuthCookie(sAuthCookIE, True) 
     Response.Redirect(system.Convert.ToString( _
              oSiteUser.GlobalPath) & "Home.ASPx")
    Else 
     CookIEAuthentication.RedirectFromLoginPage( _
                   sAuthCookIE, True)
    End If
   Else
    'login failed
    Response.Redirect("LoginFailed.ASPx")
   End If
  Else
   'login failed
   Response.Redirect("LoginFailed.ASPx")
  End If
 Else
  'login failed
  Response.Redirect("LoginFailed.ASPx")
 End If
End Sub
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved