当前位置: 移动技术网 > IT编程>开发语言>.net > NET移植案例学习:建造Web站点(6)

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

2019年01月20日  | 移动技术网IT编程  | 我要评论

面包机制作面包方法,千之刃,中央电视台8套电视剧

图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.x"
    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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网