AnsweredAssumed Answered

Create Token VB.Net

Question asked by jay.kapalczynski on Aug 18, 2014
Latest reply on Jan 17, 2018 by shaikhrizuan

Trying to create a Token at my initial login page.

I think I may have some syntax error but cant figure out where....ANY ideas?

 

Imports System.Data.SqlClient

Imports System.Net.Mail

Imports System.Data

Imports System.IO

Imports System.Web.Configuration

Imports System.Web.UI

Imports System.Net

 

Partial Class Login

Inherits System.Web.UI.Page

Public username As String = ""

Public password As String = ""

 

Protected Sub LoginButton_Click(sender As Object, e As EventArgs)

      username = Login1.UserName

      password = Login1.Password

      Session("username") = username

      Session("password") = password

     Dim sConn As String

      sConn = System.Configuration.ConfigurationManager.ConnectionStrings("SQLConnection").ToString

     Dim sqlConn As New SqlConnection(sConn)

     Dim sqlcomm As New SqlCommand("select * from users_test where username='" & username & "'and password ='" & password & "'", sqlConn)

      sqlcomm.CommandType = Data.CommandType.Text

     Dim rdrloginexists As SqlDataReader

      sqlConn.Open()

      rdrloginexists = sqlcomm.ExecuteReader

 

     Dim myDT As DataTable = New DataTable

       myDT.Load(rdrloginexists)

 

      sqlConn.Close()

      Create_Token(username, password, "123456")

End Sub

 

Public Sub Create_Token(ByVal username As String, ByVal password As String, ByVal clientid As String)

           Dim referer As String = "http://ourServer.gov/login.aspx"

     Dim expiration = "2014"

 

     Dim tokenUrl As String = "https:/http://ourServer.gov/login.aspx/Create_Token?username=" & username & "&password=" & password & "&referer=" & referer & "&expiration=" & expiration & "&f=json"

 

     Dim tokenRequest = DirectCast(WebRequest.Create(tokenUrl), HttpWebRequest)

      tokenRequest.Referer = referer

     Dim token1 = tokenRequest.GetResponse()

     Using stream As Stream = token1.GetResponseStream()

          Dim reader As New StreamReader(stream, Encoding.UTF8)

          Dim responseString As [String] = reader.ReadToEnd()

     End Using

End Sub

 

End Class

Outcomes