Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Log-in form question

Log-in form question

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestiondatabaselinq
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 8761667
    wrote on last edited by
    #1

    Imports Microsoft.AspNet.Identity
    Imports Microsoft.AspNet.Identity.EntityFramework
    Imports Microsoft.AspNet.Identity.Owin
    Imports System.Linq
    Imports System.Web
    Imports System.Web.UI
    Imports Microsoft.Owin.Security

    Partial Public Class Account_Login
    Inherits Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    RegisterHyperLink.NavigateUrl = "Register"
    OpenAuthLogin.ReturnUrl = Request.QueryString("ReturnUrl")
    Dim returnUrl = HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
    If Not [String].IsNullOrEmpty(returnUrl) Then
    RegisterHyperLink.NavigateUrl += "?ReturnUrl=" & returnUrl
    End If
    End Sub

     Protected Sub LogIn(sender As Object, e As EventArgs) Handles btnLogin.Click
    
    If IsValid Then ' Validate the user password             
    
        Dim manager = New UserManager()
    
        Dim user As ApplicationUser = manager.Find(username.Text, password.Text)
    
        Try
    
            If user IsNot Nothing Then
    
                IdentityHelper.SignIn(manager, user, RememberMe.Checked)
    
                IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
    
            End If
    
        Catch ex As Exception
    
            FailureText.Text = ex.Message
    
            ErrorMessage.Visible = True
    
        End Try
    
    End If
    

    End Sub

    End Class

    No error message is generated but when I complete the log-in form nothing happens after I press the Submit button. When the user logs in and his credentials are validated against the database, the form should ideally disappear and the user is sent to a Classic ASP Web site already on the WWW. That is, that particular Web site is not part of this small ASP.NET project whose pages will be 'sellotaped' onto that Classsic ASP site. (Eventually, I may try to do that site in ASP.NET but it would be too ambitious for me to try it now.) How would I code that in my Login.aspx.vb file, or add to the script above, because in the script above there is no reference to a URL path as in 'when you click on the Go/Submit button, make this log-in form disappear, and take me to www.mysite.com'? Thanks for reading.

    J 1 Reply Last reply
    0
    • M Member 8761667

      Imports Microsoft.AspNet.Identity
      Imports Microsoft.AspNet.Identity.EntityFramework
      Imports Microsoft.AspNet.Identity.Owin
      Imports System.Linq
      Imports System.Web
      Imports System.Web.UI
      Imports Microsoft.Owin.Security

      Partial Public Class Account_Login
      Inherits Page
      Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
      RegisterHyperLink.NavigateUrl = "Register"
      OpenAuthLogin.ReturnUrl = Request.QueryString("ReturnUrl")
      Dim returnUrl = HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
      If Not [String].IsNullOrEmpty(returnUrl) Then
      RegisterHyperLink.NavigateUrl += "?ReturnUrl=" & returnUrl
      End If
      End Sub

       Protected Sub LogIn(sender As Object, e As EventArgs) Handles btnLogin.Click
      
      If IsValid Then ' Validate the user password             
      
          Dim manager = New UserManager()
      
          Dim user As ApplicationUser = manager.Find(username.Text, password.Text)
      
          Try
      
              If user IsNot Nothing Then
      
                  IdentityHelper.SignIn(manager, user, RememberMe.Checked)
      
                  IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
      
              End If
      
          Catch ex As Exception
      
              FailureText.Text = ex.Message
      
              ErrorMessage.Visible = True
      
          End Try
      
      End If
      

      End Sub

      End Class

      No error message is generated but when I complete the log-in form nothing happens after I press the Submit button. When the user logs in and his credentials are validated against the database, the form should ideally disappear and the user is sent to a Classic ASP Web site already on the WWW. That is, that particular Web site is not part of this small ASP.NET project whose pages will be 'sellotaped' onto that Classsic ASP site. (Eventually, I may try to do that site in ASP.NET but it would be too ambitious for me to try it now.) How would I code that in my Login.aspx.vb file, or add to the script above, because in the script above there is no reference to a URL path as in 'when you click on the Go/Submit button, make this log-in form disappear, and take me to www.mysite.com'? Thanks for reading.

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Member 8761667 wrote:

      RegisterHyperLink.NavigateUrl = "Register"

      Should that be "Register.aspx" or something with an extension

      M 1 Reply Last reply
      0
      • J jkirkerx

        Member 8761667 wrote:

        RegisterHyperLink.NavigateUrl = "Register"

        Should that be "Register.aspx" or something with an extension

        M Offline
        M Offline
        Member 8761667
        wrote on last edited by
        #3

        Hello 8761667 Thanks for your reply. I have tried it with "Register.aspx" and debugged and got no errors. My Log-in form popped up and I entered the name and password of a user in the database. It searched for a few seconds - at least that's what I think it was doing behind the scenes - before the username remained in its field and the password disappeared. I did exactly the same but this time only with "Register". Again, no errors. I completed the form again and the same happened, only quicker. I don't get any errors such as 'username/password invalid'. Could the form actually be working, but it does not know where to direct the user to as I have not stimulated a kind of 'if credentials are correct send the user to www.mysite.com' type of script? Thanks again.

        J 1 Reply Last reply
        0
        • M Member 8761667

          Hello 8761667 Thanks for your reply. I have tried it with "Register.aspx" and debugged and got no errors. My Log-in form popped up and I entered the name and password of a user in the database. It searched for a few seconds - at least that's what I think it was doing behind the scenes - before the username remained in its field and the password disappeared. I did exactly the same but this time only with "Register". Again, no errors. I completed the form again and the same happened, only quicker. I don't get any errors such as 'username/password invalid'. Could the form actually be working, but it does not know where to direct the user to as I have not stimulated a kind of 'if credentials are correct send the user to www.mysite.com' type of script? Thanks again.

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          I've never coded in entity framework. but you should be able to run the code in visual studio select the line you want to start at by pressing F9, and the line will turn yellow Press F5, and run the code in the web dev server, and you should be able to walk the code by pressing F11, to go 1 line at a time. From there, you can see what happens I suspect the if Page.IsValid doesn't really work and the page does nothing, and the username stays but the password is cleared which is normal behavior for nothing happening.

          M 1 Reply Last reply
          0
          • J jkirkerx

            I've never coded in entity framework. but you should be able to run the code in visual studio select the line you want to start at by pressing F9, and the line will turn yellow Press F5, and run the code in the web dev server, and you should be able to walk the code by pressing F11, to go 1 line at a time. From there, you can see what happens I suspect the if Page.IsValid doesn't really work and the page does nothing, and the username stays but the password is cleared which is normal behavior for nothing happening.

            M Offline
            M Offline
            Member 8761667
            wrote on last edited by
            #5

            Hello jkirkerx Thanks for your reply. With my cursor flashing before the If IsValid, the line turns brown alongside a large red dot after pressing F9. I press F5 and the cursor jumps to this line above my If IsValid:

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

            That line is highlighted in yellow alongside a large red dot with a yellow arrow inside. I press F11 two or the times and it moves down highlighting lines in yellow until it jumps to this:

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

            in Site.master, and after a couple more F11s, it shows this:

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

            in a file called 'OpenAuthProviders.ascx.vb, and then it starts to go through modernizr-2.6.2.js It cursor/yellow lines seem to be jumping all over the place!

            J 1 Reply Last reply
            0
            • M Member 8761667

              Hello jkirkerx Thanks for your reply. With my cursor flashing before the If IsValid, the line turns brown alongside a large red dot after pressing F9. I press F5 and the cursor jumps to this line above my If IsValid:

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

              That line is highlighted in yellow alongside a large red dot with a yellow arrow inside. I press F11 two or the times and it moves down highlighting lines in yellow until it jumps to this:

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

              in Site.master, and after a couple more F11s, it shows this:

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

              in a file called 'OpenAuthProviders.ascx.vb, and then it starts to go through modernizr-2.6.2.js It cursor/yellow lines seem to be jumping all over the place!

              J Offline
              J Offline
              jkirkerx
              wrote on last edited by
              #6

              That happens. Set a break point on Page.IsValid, then set another on the line below, when the first one hits, press F5 to skip to the next break point, and see if that hits. F11 walks, F5 executes to until a break point is found. If it doesn't break on the 2nd break point, then the page is not valid. Sometimes you can't walk code, or the code breaks to other code pages before you get to what you want. So You have to strategize on setting breakpoints. You'll get better at it, over time.

              M 1 Reply Last reply
              0
              • J jkirkerx

                That happens. Set a break point on Page.IsValid, then set another on the line below, when the first one hits, press F5 to skip to the next break point, and see if that hits. F11 walks, F5 executes to until a break point is found. If it doesn't break on the 2nd break point, then the page is not valid. Sometimes you can't walk code, or the code breaks to other code pages before you get to what you want. So You have to strategize on setting breakpoints. You'll get better at it, over time.

                M Offline
                M Offline
                Member 8761667
                wrote on last edited by
                #7

                OK, there are two breakpoints:

                If IsValid Then ' Validate the user password

                      Dim manager = New UserManager()
                

                When I then press F5 here: If IsValid it quickly loads up the browser and highlights everything in yellow in that modernizr js file. It didn't go from one breakpoint to the other, so that would indicate an invalid file, do you think?

                J 1 Reply Last reply
                0
                • M Member 8761667

                  OK, there are two breakpoints:

                  If IsValid Then ' Validate the user password

                        Dim manager = New UserManager()
                  

                  When I then press F5 here: If IsValid it quickly loads up the browser and highlights everything in yellow in that modernizr js file. It didn't go from one breakpoint to the other, so that would indicate an invalid file, do you think?

                  J Offline
                  J Offline
                  jkirkerx
                  wrote on last edited by
                  #8

                  I think it's running the page validator script now, you'll have to see if the script runs to the end and get to Dim manager = new UserManager(), put a breakpoint there

                  M 1 Reply Last reply
                  0
                  • J jkirkerx

                    I think it's running the page validator script now, you'll have to see if the script runs to the end and get to Dim manager = new UserManager(), put a breakpoint there

                    M Offline
                    M Offline
                    Member 8761667
                    wrote on last edited by
                    #9

                    It looks to me as if it has stopped. In the very bottom left of the software it says 'Ready'. Everything has stopped in modernizr. It has stopped here at the very top of modernizr:

                    window.Modernizr = (function( window, document, undefined ) {

                    and has a red spot next to it with a yellow arrow inside it, and the Immediate Window is blank.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups