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

2016-01-29 19:21 4 1 收藏

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

【 tulaoshi.com - 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

 

来源:https://www.tulaoshi.com/n/20160129/1509146.html

延伸阅读
标签: Web开发
最近,许多Web站点开始在开发人员社区当中引起关注。这些站点独特之处在于,它们更像是桌面应用程序而非Web应用程序。当您与它们交互时,它们可以快速在浏览器显示无穷的信息而又无需重新加载页面。 例如,在Google Maps站点(http://maps.google.com/),您可以单击地图,缩小或者放大,然后随心所欲地来回移动鼠标。浏览器会连续地...
标签: Java JAVA基础
  JSP是由Sun微系统公司于1999年6月推出的一项技术,是基于JavaServlet以及整个java体系的Web开发技术,利用这一技术可以建立先进、安全和跨平台的动态网站。 JSP 与ASP非常相似。两者都提供在HTML 代码中混合某种程序代码、由语言引擎解释执行程序代码的能力。在ASP或JSP 环境下,HTML代码主要负责描述信息的显示样式,而程序代码则用来...
using System; class EnumExample { public enum TimeOfDay :int { Morning=0, Afternoon=1, Evening=2 } public static int Main() { WriteGreeting(TimeOfDay.Morning); return 0; } static void WriteGreeting(TimeOfDay timeOfDay) { switch(timeOfDay) { case TimeOfDay.Morning: Console.WriteLine("Good morning!"); bre...
标签: ASP
       为什么需要Web Service       在通过internet网购买商品后,你可能对配送方式感到迷惑不解。经常的情况是因配送问题找配送公司而消耗你的大量时间,对于配送公司而言这也不是一项增值服务。       为了解决这种问题,配送公司需要在不降低安全级别的...
标签: ASP
          创建Web Service       我将用c#创建一个Web Service 叫SecurityWebService。一个Web Service文件的扩展名是:.asmx(就象asp.net的文件扩展名.aspx那样),文件的第一行是:      <%@ WebService Language="C#" class="SecurityWebSe...

经验教程

697

收藏

9
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部