473,399 Members | 2,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,399 software developers and data experts.

ASP.NET Forms Authentication Questions...

Background:
I want to be able to authenticate users whose usernames & passwords are
stored in a SQL database.
I only want certain pages to require authentication.

I have tried to implement this by creating the following class

public class SecuredPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!User.Identity.IsAuthenticated)
Response.Redirect("./Login.aspx");
}
}

I then have all of the pages that I want to be secured inherit the
SecuredPage class.

Problem:
User.Identity.IsAuthenticated refers to the local windows account of the
user accessing the page.

I can write a function that verifies the identity of a user by going out and
checking the database, but I don't want this to happen everytime the page
loads.

I am thinking that I could use session state to store the current user's
credentials once first obtained, and check the session variables first before
going out to SQL for authentication.

Question:
Am I correct in assuming that "Forms Authentication" is applied sitewide?
Would I have to create child web applications to isolate the pages I want
secured? If this is the case, and I'm not interested in either requiring
sitewide authentication or creating child web applications to implement
security, what do you think about the following ideas?

Could I store a boolean value in session state once a user has been
authenticated so that I can reference that on Page_Loads as opposed to
quering SQL? Would that make it too easy for a hacker to get into my site?
As an alternative, is it safe to store an encrypted username and password in
session state after initial authentication? Are there any security concerns
in doing this?

Are the meathods I'm considering "Forms Authentication"?

What is the "best practice" implementation for the authentication I'm trying
to achieve?

Thanks in advance for your help!

Paul Daly
Oct 27 '05 #1
1 1635
My suggestion is instead of "rolling your own", use what .NET has provided
you. Put the pages that need authroization in their own folder with a
web.config that sets up authorization. Boom, done!

David

======================================
David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485
"Paul Daly (MCP)" wrote:
Background:
I want to be able to authenticate users whose usernames & passwords are
stored in a SQL database.
I only want certain pages to require authentication.

I have tried to implement this by creating the following class

public class SecuredPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!User.Identity.IsAuthenticated)
Response.Redirect("./Login.aspx");
}
}

I then have all of the pages that I want to be secured inherit the
SecuredPage class.

Problem:
User.Identity.IsAuthenticated refers to the local windows account of the
user accessing the page.

I can write a function that verifies the identity of a user by going out and
checking the database, but I don't want this to happen everytime the page
loads.

I am thinking that I could use session state to store the current user's
credentials once first obtained, and check the session variables first before
going out to SQL for authentication.

Question:
Am I correct in assuming that "Forms Authentication" is applied sitewide?
Would I have to create child web applications to isolate the pages I want
secured? If this is the case, and I'm not interested in either requiring
sitewide authentication or creating child web applications to implement
security, what do you think about the following ideas?

Could I store a boolean value in session state once a user has been
authenticated so that I can reference that on Page_Loads as opposed to
quering SQL? Would that make it too easy for a hacker to get into my site?
As an alternative, is it safe to store an encrypted username and password in
session state after initial authentication? Are there any security concerns
in doing this?

Are the meathods I'm considering "Forms Authentication"?

What is the "best practice" implementation for the authentication I'm trying
to achieve?

Thanks in advance for your help!

Paul Daly

Oct 28 '05 #2

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

Similar topics

3
by: john | last post by:
I have 2 questions: 1. I am trying to use forms authentication. When the user logs out, I make these function calls: Session.Abandon(); FormsAuthentication.SignOut(); But after they log out,...
9
by: Hermit Dave | last post by:
Hi, I am making a web application (rather two applications) one which is host and used by customers when they are just browsing through products. The second application resides on a secure...
1
by: The Eeediot | last post by:
Hello, ASP.NET gurus! I have read many pages on setting up a login screen to access a number of web pages using Forms Authentication and I am still trying to wrap my brain around the whole thing. ...
0
by: William F. Zachmann | last post by:
A web site that will run on Windows Server 2003 and IIS 6.0 needs to provide three levels of access, one for the public and two others for two levels of subscribers. This is a port of a prior site...
18
by: Rippo | last post by:
Hi I am using role base forms authentication in asp.net and have come across a problem that I would like advice on. On a successful login a session variable is set to identify a user. This is...
5
by: Cesar | last post by:
Hello, I have an application that is using forms authentication and it seems to be working fine most of the time. Unfortunatelly, it sometimes just redirects me to the login screen. It seems that...
4
by: WebBuilder451 | last post by:
I have an app that will direct to the login on any unauthorized access. It will redirect back to the calling page when authenticated. Now here is the problem. I'm allowing for user registration...
1
by: Paul Daly (MCP) | last post by:
Background: I want to be able to authenticate users whose usernames & passwords are stored in a SQL database. I only want certain pages to require authentication. I have tried to implement this...
5
by: Rory Becker | last post by:
Having now created a Custom MembershipProvider that seems to work correctly with my Logon and ChangePassword controls, I am, as they say, a happy bunny. The next stange is to move on to the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.