Ok, I will do my best.

I need more details as to what the problem is. Provide code where you can, and I need you to answer a few questions:

1. Did you just copy and paste my code?
2. Are you using an Access or an SQL Database?
3. To clarify what you have said, you get a successful login with correct or incorrect data??
4. Are you using Visual Studio, ASP.Net Web Matrix, or something else? Why I am asking this, is to see if you have put breakpoints in your code to follow what data is being passed around.

The if you answer NO to the first question, please provide the code (or personal message me) so I can go through it for you.

Excuse me I am a novice in asp.net and i prove to create a new alogin application wirh this code, but my page don't make any check on the table when I make the submit return all the time at the login page. i prove to enter correct data and wrong data can yiou help me please??? :sad: :sad:

In advance thanks for your help.
1. I have copy all your code code that you have posted and I download the txt file that you have putted in the thread.
2. I have used for commodity the database ACCESS. (I make the prove with my database and with your database)
3. I don't now if the login goes well or not remain in all the case in the login page, probably return always a incorect login.
4. I using Visual Studio.Net.

To help you to help me I put the sorces code that I have entered in my page.

Thanks a lot for your help.

I have made other prove and I have correct the path of the database in the web.config, i put the correct path, but the objReader.Read() return always a true value.
I substitute the stored procedures with a normal query select * from usr_user but the result don't change the objReader.Read() is true, where is my error?? :cry: :cry:

Thanks for your help

I dont really know how your wanting to go about this login but it doesnt look like its the same as Paladines. In his example he is making sure that "1" user in the database has a username password that match what was put into the textboxes. Example

SELECT COUNT(*) AS Num_of_User
FROM tblUser
WHERE (((tblUser.U_Name)=[@UserName]) AND ((tblUser.U_Password)=[@Password]));

Notice "COUNT" if the query finds a username and password that match in the database it gonna return a value of "1"

While objReader.Read()
                If CStr(objReader.GetValue(0)) <> "1" Then
                    lblMessage.Text = "Invalid Login!"
                Else
                    objReader.Close()   '   |||||   Close the Connections & Reader
                    Return True
                End If

Notice the .GetValue(0)) <> "1". Meaning if the value is not = "1" then "Invalid Login" During Paladines query if it doesnt find the matching username and password it will return a value of "0" therefore will not allow the login to take place.

So that being said if you want to do it the way he is you must change your Stored Procedure to:

SELECT COUNT(*) AS Num_of_User
FROM USR_USER
WHERE (((USR_USER.USR_USERID)=[@UserName]) AND ((USR_USER.USR_PASSWORD)=[@Password]));

I have went ahead and fixed it for you in your database so try it and tell me what you come up with.

Miller

Thanks a lot Miller it's really a stupid error, I make an error to the generation of the query.
It's obvous that the login page return always a different value for this field.
Thanks for your help and good work.

:lol: :lol:

np man just trying to give back to da community. This site has helped me out alot.

Miller

Can somebody help me please? It Just Doesn't accept the Catch ex As Exception statement. What should i do ?
Thanks in advance

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'Exception' is not defined.

Source Error:

Line 101: End While
Line 102:
Line 103: Catch ex As Exception
Line 104: outputLabel.Text = "Error Connecting to Database!"
Line 105: Finally


Source File: C:\Trial\login.aspx.vb Line: 103

Hi post the portion of code of the try-catch-finaly and if I found an error i post you the correct code.

Bye :D

just for curiosity, but you do have the try part of the try-catch block above this code??

Have you rebuilt the project?

Can somebody help me please? It Just Doesn't accept the Catch ex As Exception statement. What should i do ?
Thanks in advance

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'Exception' is not defined.

Source Error:

Line 101: End While
Line 102:
Line 103: Catch ex As Exception
Line 104: outputLabel.Text = "Error Connecting to Database!"
Line 105: Finally


Source File: C:\Trial\login.aspx.vb Line: 103

Thanks guys but i manage to find the problem. I imported oleDb exception and just change exception to oleDbexception and everything is fine now.

I think what he asked was:
Instead of
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False) ' ||||| default.aspx Page! ,
can he use, Reponse.Redirect

The answer is Yes. Response.Redirect will do the work.

In my application I also use Response.Redirect("MainMenu.apsx"). Once user
is verified and logged in then I present the main menu to the user.

I did not understand the reasoning behind FormsAuthentication.RedirectFromLoginPage() also? even after reading explanation above as well as online help :sad:

Paladine,

You are absolutely GREAT! I am a complete NEWBIE in .NET world programming. I have previous experience in C programming. Your Tutorial was extremely helpful to get someone like me started on .NET.

Infect, I was using the newer 2005 Express Edition .NET version and still everything worked. Only problem I faced was web.config was different, but,
with little more reading and debugging it got fixed.

What I still do not understand is Global.asax ? Waht is *.asax file extension? Can you list complete listing of Global.asax? In the forum, there was only one time mention of this file and that was it. I could not find anything more about it.

I also would like to add limited login attempt and set session LOGIN_IN = "YES". Help in section with little detail will be greatful.

Finally,
Paladine you are the GREATEST!
Thank you,

Thanks for the praise. Greatly appreciated, and I am glad this tutorial helped.
:p
The reason I did not get into the details of the Global.asax file or web.config, was for time, and to avoid confusion.

But since you asked I will answer your questions about them, and clear up the Response.Redirect query.

You can certainly use the method you have chosen for the Response.Redirect means of sending the user to the next page in the application. I chose to use FormsAuthentication.RedirectFromLoginPage() since it is part of the security namespace in the .net framework, and because that was then idea behind the tutorial; Security.

So for future use with things like and Authentication Ticket. encryption, and/or a Cookie. All for security (tighter). So you can use any other means you want to redirect the user. It is just the method I picked for the tutorial theme.

Global.asax file is known as the ASP.NET Application File. This file allows you to program against the HttpApplication Object - you can control the ASP.NET application as you do any other object through methods and events

...." controls application events, allowing you to execute code the first time any page in your application is requested, or even every time the page is requested"

So when ever a page in your virtual directory is requested for the first time, an HttpApplication object is instantiated.

See here for members of the this Class

Web.Config
- It holds the information used by the application to control its behavior.
- Nothing special about this file, except it does hold keys and values recognized by ASP.NET
<appSettings> - Used to store your own custom application settings
<authenication> - Configures how ASP.NET authenicates users
<browsercaps> - Responsible for controlling the settings of the browser capabilities component.

  • As for the response to setting a limited number of attempts to login, I have already shown that with the session variable(s).

Hope this helps..

:cool:

In my application I also use Response.Redirect("MainMenu.apsx"). Once user
is verified and logged in then I present the main menu to the user.

I did not understand the reasoning behind FormsAuthentication.RedirectFromLoginPage() also? even after reading explanation above as well as online help :sad:

Paladine,

You are absolutely GREAT! I am a complete NEWBIE in .NET world programming. I have previous experience in C programming. Your Tutorial was extremely helpful to get someone like me started on .NET.

Infect, I was using the newer 2005 Express Edition .NET version and still everything worked. Only problem I faced was web.config was different, but,
with little more reading and debugging it got fixed.

What I still do not understand is Global.asax ? Waht is *.asax file extension? Can you list complete listing of Global.asax? In the forum, there was only one time mention of this file and that was it. I could not find anything more about it.

I also would like to add limited login attempt and set session LOGIN_IN = "YES". Help in section with little detail will be greatful.

Finally,
Paladine you are the GREATEST!
Thank you,

Paladine,

Is there anyway I can use FormsAuthentication.RedirectFromLoginPage() and specify a page name that I want to go to?, i.e., MainMenu.aspx? or am I stuck with default.aspx only?

Also, the above function is used here because we are discussing login. But, what functions you recommend instead of Response.Redirect() to go back and forth between other web pages? For Example, assume I rename my MainMenu.aspx to default.aspx. If user click on menu option then I need to go to that page and load. Will Response.Redirect() be good or another function?

I am looking for good books for refrences as well as "How To" series books on .NET with database and VB. Any suggestion?

Thank you!

P. S. You should think about writing book on .net and VB :idea:

Paladine,

Please help me clear some confusion about the page that is executed in webserver wether is IIS or another webserver. Hopefully this is going to help me understand Response.Redirect() vs. FormsAuthentication.RedirectFromLoginPage().

In any webserver one can only define one (1) main file, i.e., *.htm, *.aspx, etc, which is loaded whenever a client, i.e., internet explorer, connects.

Suppose I specify login2.aspx as that main page so whenever any of my user enters URL of my website then their browser will automatically load login page.

Now then, upon successful login it seems to me that I have to use Response.Redirect() to move that user to next page. Because if I use FormsAuthentication.RedirectFromLoginPage() then server is looking for default.aspx. I can't set default.aspx as default document as stated in earlier post, because I already have login2.aspx as my default document.

I am sorry I am having difficulty explain my problem properly. But, eventually I am trying to use FormsAuthentication.RedirectFromLoginPage() after user successfully logs in, however, I can't seems to do it without using Response.Redirect() because I want to move to page name MainMenu.aspx and not default.aspx.

Again, I hope I've explained my problem properly and you'll see my perspective to you can help me.

As always you're GREATTTTTTTTTT!

Thank you,

Thanks for the compliments. I am just glad I can help. :mrgreen:

Well I hope I can clear some things up for you:

FormsAuthentication is a means for authenticating through your asp.net application, rather than IIS. This gives you more control over your site's authenication scenarious. For example, if you store your users' credentials in a database or xml file instead of through windows.
:lol:
Looking at the methods of the FormsAuthenication Class will give you a better idea of what functionality it provides. That functionality is on a different playing field from Response.Redirect.

Response.Redirect is simple a means of redirecting a user, it in no way allows you to set security options in your application based on that redirection like FormsAuthenication does. Saying that, this does not mean you can't combine the two. ??

Example:

if txtUserName.Text = "Test" then
	FormsAuthenication.SetAuthCookie (txtUserName.Text, false)
	Response.Redirect ("MyMainMenu.aspx")
end if

You set up a cookie, and then redirect the user. I choose FormsAuthentication.RedirectFromLoginPage for my examples as just another way to do this redirection, and have the application redirect the user for me, based on the default page setup on the webserver.

[img]http://www3.telus.net/public/tmlohnes/Image1.jpg[/img]


So you could easily add Login2.aspx as a possible default page, but you dont want to do this for every case, so use Reponse.Redirect(). Nothing saying you can't do it that way, just cumbersome to add pages to the default list that the webserver looks for. Make sense?

So in your case, I would use the Response.Redirect !

Hope this helps!

Paladine,

Please help me clear some confusion about the page that is executed in webserver wether is IIS or another webserver. Hopefully this is going to help me understand Response.Redirect() vs. FormsAuthentication.RedirectFromLoginPage().

In any webserver one can only define one (1) main file, i.e., *.htm, *.aspx, etc, which is loaded whenever a client, i.e., internet explorer, connects.

Suppose I specify login2.aspx as that main page so whenever any of my user enters URL of my website then their browser will automatically load login page.

Now then, upon successful login it seems to me that I have to use Response.Redirect() to move that user to next page. Because if I use FormsAuthentication.RedirectFromLoginPage() then server is looking for default.aspx. I can't set default.aspx as default document as stated in earlier post, because I already have login2.aspx as my default document.

I am sorry I am having difficulty explain my problem properly. But, eventually I am trying to use FormsAuthentication.RedirectFromLoginPage() after user successfully logs in, however, I can't seems to do it without using Response.Redirect() because I want to move to page name MainMenu.aspx and not default.aspx.

Again, I hope I've explained my problem properly and you'll see my perspective to you can help me.

As always you're GREATTTTTTTTTT!

Thank you,

i have to get employee id automatically when employee login with his username and password and that id should get store in session
is any one can send me sample code how to do this

I want to store session of employee that is employee id when employee login with username and password store employee id as session using vb.net

i have a form where employee enter his username and password after entering he must select new form from control panel when he select form his id should get store in session

good one..really helped me alot!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.