2 different homepages

P

paul.hester

Hi all,

I'm starting out with ASP .NET. I'd like to have a homepage that shows
a completely different page depending on whether a user is logged in -
i.e. a generic welcome page if not logged in, or a user-specific
account page if logged in.

How is this normally achieved with ASP .NET? With a MultiView control,
or is there a better way to do this?

Thanks,

Paul
 
P

PeterKellner

You could use the multiview control, but I prefer to use
Response.Redirect("...")

In my Page_Load event I use code like the following. (notice that I don't
use Membership.GetUser() which would cause a database lookup)

protected void Page_Load(object sender, EventArgs e)

{

// this page is only for non authenticated users

IPrincipal iPrincipal = HttpContext.Current.User;

if (iPrincipal.Identity.IsAuthenticated)

....

Peter Kellner

http://peterkellner.net
 
J

Jan Hyde

(e-mail address removed)'s wild thoughts were released on 14
May 2006 19:48:01 -0700 bearing the following fruit:
Hi all,

I'm starting out with ASP .NET. I'd like to have a homepage that shows
a completely different page depending on whether a user is logged in -
i.e. a generic welcome page if not logged in, or a user-specific
account page if logged in.

How is this normally achieved with ASP .NET? With a MultiView control,
or is there a better way to do this?

You could also use the login view

'The LoginView control allows you to display different
information to anonymous and logged-in users. The control
displays one of two templates: the AnonymousTemplate or the
LoggedInTemplate. In the templates, you can add markup and
controls that display information appropriate for anonymous
users and authenticated users, respectively.'



Jan Hyde (VB MVP)
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top