ASP.NET: How to conditionally display content based on login/authentication?

G

Guest

One thing I did a lot of in Classic ASP involved showing page elements
conditionally based on whether a user was logged in or not. Logged in users
or "superusers" would get more content and/or more controls if my pages
detected their login. Non-logged in users would also get some page content
at a given URL, but the protected content was hidden from them.

I would like to know generally how this is done in ASP.NET. I'm particularly
interested in understanding how you make this happen within the froms
authentication/authorization framework that's built into ASP.NET 1.1 or 2.0.

Lots of tutorials online show me how to boot people off page and back to
login if they aren't logged in. This isn't what I want. I'd like to show
non-logged in folks a minimal version of the page, and show logged-in folks
a lot more.

Pretty sure this is a simple thing involving a session variable or somesuch.
Can someone point the way to the best practice?

-KF
 
G

Guest

Thank you. Can someone show me some code?

Specifically, I'm wondering what object or widget or attribute I inspect to
make the determination about whether visiblility should be on or off.

Thanks,
-KF
 
G

Guest

Partially answering my own question, this link has some good information and
C# samples:
http://www.eggheadcafe.com/articles/20020906.asp

msdn article on C# and forms-based auth:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q301240&ID=kb;en-us;Q301240&SD=MSDN

Very good basic discussion of ASP.NET 1.x authentication methods
http://www.4guysfromrolla.com/webtech/110701-1.shtml

The end of this page addresses the question of managing visibility by roles:
http://www.xoc.net/works/tips/forms-authentication.asp

This page has C# samples that also set visibiliity based on roles:
http://www.codeproject.com/aspnet/formsroleauth.asp

Authentication in 2.0:
http://www.awprofessional.com/articles/article.asp?p=351414

-KF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top