Log-in form question
-
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.SecurityPartial 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 SubProtected 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.
-
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.SecurityPartial 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 SubProtected 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.
-
Member 8761667 wrote:
RegisterHyperLink.NavigateUrl = "Register"
Should that be "Register.aspx" or something with an extension
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.
-
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.
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.
-
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.
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!
-
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!
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.
-
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.
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?
-
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?
-
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
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.