Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8661583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:31:50+00:00 2026-06-12T16:31:50+00:00

Here is whats happening , If the user is logged in – this is

  • 0

Here is whats happening , If the user is logged in – this is called directly from Page_Load

Protected Sub EnterNewTransInDb()
        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("connstring").ConnectionString)
        Dim comm As New SqlCommand("INSERT INTO tblRegisterRedirect (RegID , UserID, EventID, TimeStamp) VALUES (@RegID, @UserID, @EventID , getdate()) ;", conn)

        Dim RegID As Guid
        RegID = Guid.NewGuid()
        Dim GIUDuserid As Guid
        GIUDuserid = New Guid(HttpContext.Current.Request.Cookies("UserID").Value.ToString())
        Dim GIUDevnetid As New Guid(HttpContext.Current.Request.QueryString("id").ToString())
        comm.Parameters.AddWithValue("@RegID", RegID)
        comm.Parameters.AddWithValue("@UserID", GIUDuserid)
        comm.Parameters.AddWithValue("@EventID", GIUDevnetid)

        Try
            conn.Open()
            Dim i As Integer = comm.ExecuteNonQuery()
            conn.Close()
        Catch ex As Exception
            Dim errors As String = ex.ToString()
        End Try
        Dim URL As String = Request.QueryString("url").ToString()
        Response.Redirect(URL + "?aid=854&rid=" + RegID.ToString())
    End Sub

This works great, but if their not logged in , then they enter their log-in credentials – this happens on Button_Click event, in the click event I call this function EnterNewTransInDb() , When I run it this time , after logging in – SAME CODE , it throws an exception – Object reference is null – referring to the querystring

 Protected Sub btnLogin_Click(sender As Object, e As System.EventArgs) Handles btnLogin.Click
      'took out code SqlConnection onnection and SqlDataReader Code
        dbCon.Open()            

        'If Email and PW are found
        If dr.Read Then
            Dim appCookie As New HttpCookie("UserID")
            appCookie.Value = dr("GUID").ToString()
            appCookie.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie)

            Dim appCookie1 As New HttpCookie("UserName")
            appCookie1.Value = dr("UserName").ToString
            appCookie1.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie1)

            Dim appCookie2 As New HttpCookie("UserEmail")
            appCookie2.Value = txtEmail.Text.ToLower()
            appCookie2.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie2)

            Dim appCookie3 As New HttpCookie("Lat")
            appCookie3.Value = dr("GeoLat").ToString()
            appCookie3.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie3)

            Dim appCookie4 As New HttpCookie("Long")
            appCookie4.Value = dr("GeoLong").ToString()
            appCookie4.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie4)

            Dim appCookie5 As New HttpCookie("City")
            appCookie5.Value = dr("City").ToString()
            appCookie5.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie5)

            Dim appCookie6 As New HttpCookie("State")
            appCookie6.Value = dr("State").ToString
            appCookie6.Expires = DateTime.Now.AddDays(30)
            HttpContext.Current.Response.Cookies.Add(appCookie6)

            HttpContext.Current.Response.Cookies("EO_Login").Expires = Now.AddDays(30)
            HttpContext.Current.Response.Cookies("EO_Login")("EMail") = txtEmail.Text.ToLower()

            Dim sUserData As String = HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request.Cookies("UserID").Value) & "|" & HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request.Cookies("UserName").Value) & "|" & HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request.Cookies("UserEmail").Value)
            ' Dim sUserData As String = "dbcf586f-82ac-4aef-8cd0-0809d20c70db|scott selby|scottselby@live.com"
            Dim fat As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, _
                     dr("UserName").ToString, DateTime.Now, _
                     DateTime.Now.AddDays(6), True, sUserData, _
                     FormsAuthentication.FormsCookiePath)
            Dim encTicket As String = FormsAuthentication.Encrypt(fat)
            HttpContext.Current.Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName, encTicket))

            'If Email and Pw are not found
        Else
            dr.Close()
            dbCon.Close()

        End If

        'Always do this
        dr.Close()
        sSql = "UPDATE eo_Users SET LastLogin=GETUTCDATE() WHERE GUID=@GUID; "
        cmd = New SqlCommand(sSql, dbCon)
        cmd.Parameters.AddWithValue("@GUID", HttpContext.Current.Session("UserID"))
        cmd.ExecuteNonQuery()
        dbCon.Close()
        EnterNewTransInDb()
        'Dim URL As String = Request.QueryString("url").ToString()
        'Response.Redirect(URL + "?aid=854&rid=" + RegID.ToString())
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:31:52+00:00Added an answer on June 12, 2026 at 4:31 pm

    Assuming you only want this code to run if there is a valid QueryString, you could put a guard clause at the beginning of the method to simply check if QueryString is null and then perform some other action if this page is called without a QueryString.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(LocalVariable)ABC.string(Name) = (IDataReader)dataReader.GetString(0); This name value is coming from database. What happening here is
I don't quite understand whats happening here a=[1,2,3,4] b=[5,6,7,8] a[len(a):] = b seems to
This is a bit of an odd situation. Here's what's happening. So, we have
This is my first experience with javascript, and... Well... Ugh. Here's what's happening: function
Here's a quick step by step of what's been happening. The user adds a
If i have a string as such I am not here... \n..Hello\n.\n....Whats happening I
Im getting a funny MySQL error. Here's whats happening: query: SELECT COUNT(id) AS mycount
I have what appears to be a corrupt index? Here is what is happening.
My delete method is not working, here is what is happening at the moment.
What's happening here : $ echo $SHELL /bin/bash $ echo -e foo foo $

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.