Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Guest
 
Posts: n/a
#1: Nov 19 '05
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



Jacek Stawicki
Guest
 
Posts: n/a
#2: Nov 19 '05

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


I think that metodology for this issue is everywhere the same! Just try
manipulate with some controls e.g. Panel, set property Visible=true when user
is logged and Visible=false where not.
In ASP.Net 2.0. you have pretty nice WebControl LoginView:
http://beta.asp.net/QUICKSTART/aspne...loginview.aspx



--
C# Dev


"kenfine@u.washington.edu" wrote:
[color=blue]
> 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
>
>
>[/color]
Guest
 
Posts: n/a
#3: Nov 19 '05

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


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


"Jacek Stawicki" <JacekStawicki@discussions.microsoft.com> wrote in message
news:40266011-11A7-476F-A534-350968FCFFC7@microsoft.com...[color=blue]
>I think that metodology for this issue is everywhere the same! Just try
> manipulate with some controls e.g. Panel, set property Visible=true when
> user
> is logged and Visible=false where not.
> In ASP.Net 2.0. you have pretty nice WebControl LoginView:
> http://beta.asp.net/QUICKSTART/aspne...loginview.aspx
>
>
>
> --
> C# Dev
>
>
> "kenfine@u.washington.edu" wrote:
>[color=green]
>> 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
>>
>>
>>[/color][/color]


Guest
 
Posts: n/a
#4: Nov 19 '05

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


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...301240&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/articl...e.asp?p=351414

-KF


<kenfine@u.washington.edu> wrote in message
news:urSn4YhkFHA.1464@TK2MSFTNGP14.phx.gbl...[color=blue]
> 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
>
>
> "Jacek Stawicki" <JacekStawicki@discussions.microsoft.com> wrote in
> message news:40266011-11A7-476F-A534-350968FCFFC7@microsoft.com...[color=green]
>>I think that metodology for this issue is everywhere the same! Just try
>> manipulate with some controls e.g. Panel, set property Visible=true when
>> user
>> is logged and Visible=false where not.
>> In ASP.Net 2.0. you have pretty nice WebControl LoginView:
>> http://beta.asp.net/QUICKSTART/aspne...loginview.aspx
>>
>>
>>
>> --
>> C# Dev
>>
>>
>> "kenfine@u.washington.edu" wrote:
>>[color=darkred]
>>> 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
>>>
>>>
>>>[/color][/color]
>
>[/color]


Closed Thread