NET移植案例学习:建造Web站点(6)
程序员文章站
2023-02-21 08:12:03
图3 config.web文件
<?xml version="1.0" encoding="utf-8" ?>
<configura...
图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
<?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