473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Login security in ASP.net

Hello Everybody,

I have one login page and other pages which will be shown only if user
logs successfully. If someone tries to access page without
identification then she should be directed to login page.

I have following code

after successful login I do...
Session("UserID") = txtUser.Text.Trim()
In every page_load I have code...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
curUser = CStr(Session("UserID"))
If Len(curUser) = 0 Then
Response.Redirect("./Default.aspx")
End If

End Sub

and in logout button I have...
Private Sub cmdLogout_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdLogout.Click
Session("UserID") = ""
Session("UserName") = ""
curUser = ""
Session.Abandon()
Response.Redirect("./Default.aspx")
End Sub
but it doesn't work. Even after logging out. Other pages can be accessed
straight. I don't know why. Can someone help me? Thanks in advance.

Regards,
Pravin
Nov 18 '05 #1
2 993
Dont' reinvent the wheel. Use the built-in Forms Authentication which
already provides this kind of functionality more gracefully than you are
doing it.
Here's more info:
http://www.dotnetbips.com/displayarticle.aspx?id=9
http://www.4guysfromrolla.com/webtech/121901-1.2.shtml
http://www.dotnetbips.com/displayarticle.aspx?id=117

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Pravin A. Sable" <my***********@ccs.neu.edu> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Hello Everybody,

I have one login page and other pages which will be shown only if user
logs successfully. If someone tries to access page without
identification then she should be directed to login page.

I have following code

after successful login I do...
Session("UserID") = txtUser.Text.Trim()
In every page_load I have code...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
curUser = CStr(Session("UserID"))
If Len(curUser) = 0 Then
Response.Redirect("./Default.aspx")
End If

End Sub

and in logout button I have...
Private Sub cmdLogout_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdLogout.Click
Session("UserID") = ""
Session("UserName") = ""
curUser = ""
Session.Abandon()
Response.Redirect("./Default.aspx")
End Sub
but it doesn't work. Even after logging out. Other pages can be accessed
straight. I don't know why. Can someone help me? Thanks in advance.

Regards,
Pravin

Nov 18 '05 #2
Exactly. You're doing it the old ASP way. Forms Auth is working great for
me.

-Max

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
Dont' reinvent the wheel. Use the built-in Forms Authentication which
already provides this kind of functionality more gracefully than you are
doing it.
Here's more info:
http://www.dotnetbips.com/displayarticle.aspx?id=9
http://www.4guysfromrolla.com/webtech/121901-1.2.shtml
http://www.dotnetbips.com/displayarticle.aspx?id=117

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: mo | last post by:
Sorry I can't be more specific, but.... I'd like to create a secure login from an ASP page to a specific SQL Server 2000 Db. Is there an accepted methodology for doing this? Are there any...
4
by: rrober07 | last post by:
Hello, My Setup is I have a Web Server machine(Devweb01), Database SQL Machine(Devsql01), a Client Machine(local machine) I have configured the SQL machine as follows: 1) Added local Aspnet...
19
by: Siobhan | last post by:
Hi What is the recommended way to store a user's database credentials across the pages of a web application so that each time the database is accessed the system doesn't have to ask them for their...
10
by: et | last post by:
I have an asp.net program that uses a connection string, using integrated security to connect to a sql database. It runs fine on one server, but the other server gives me the error that "Login...
1
by: beachboy | last post by:
how can pass the login (security info) to secondary application? ASP.NET 1.1 user login to application 1(app1.myapp.com) with their username and password, then they have a link to application 2...
1
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to...
7
by: Samuel Shulman | last post by:
Is there a method that will indicate the person who logged successfully is Logged and therefore allowed to browse freely other then using the...
0
by: muder | last post by:
I have a standard Login ASP.NET 2.0 control on a login Page, a LoginName and LoginStatus controls on the member's page. once the user login successfully I am redirecting the user to Member.aspx...
6
by: Kat | last post by:
Every time I attempt to run a localhost website, it asks me for a login, as if I am not a user on the local machine. I am a user on the local machine, I am an admin on the local machine. I am not...
4
by: Brett | last post by:
I have an ASP.NET 2.0 application that uses Forms Authentication. The startup page contains just a login control, and the site works well on an IIS 6 web server. I am now setting the site up on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.