Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > LoginView - I'm probably trying to use it in a way that's not intended...

Thread Tools

LoginView - I'm probably trying to use it in a way that's not intended...

Homer J. Simpson
Posts: n/a
I think I "get" the basic loginview control, based on form authentication
samples I keep seeing. I can get basic functionality out of it (works
great), but the more I try to take it a step beyond (customizing it), the
more I think my customizations are being done in such a way that doesn't fit
the mold. I need somebody to either confirm my efforts are futile, or show
me the right way.

I have a page with a bunch of controls I'd like to have displayed, whether
the user is authenticated or not.

This is followed by a bunch of controls that I want to either show up (if
the user is authenticated), or stay hidden (if the user isn't) and replaced
with an asp:Login control. I thought I could do the following:

[some common header, some text and various controls]
<asp:Login />
[other controls that should be displayed only if authenticated]

However, when I hit F5, I get errors (in the page's .cs file) stating that
all the references to the controls that I've declared within the
LoggedInTemplate> tags don't exist in the current context. I'm not entirely
sure why that would be the case, as these controls are only referenced in
the code-behind within the body of event handlers (eg,
ListBox1_SelectedIndexChanged(), btnAdd_Click(), etc) that could only
possibly be invoked when the user is logged in (and thus those controls are
showing). Both ListBox1 and btnAdd are controls that are part of
<LoggedInTemplate>. I tried referencing them using variants on
"LoginView1.ListBox1" and "LoginView1.LoggedInTemplate.ListBox1", but
IntelliSense doesn't seem to agree with me.

In any case, in an attempt to work around this particular problem, I've
tried moving everything I put within <LoggedInTemplate> (outside the whole
asp:LoginView, actually), and putting everything in an invisible
panel...with the intent of showing the panel in Page_Load() only if
HttpContext.Current.User.Identity.IsAuthenticated is true. I think that's
an ugly kludge, but I'll live with it if that's the way to go. Hitting F5
doesn't report any problem, but now as soon as the browser loads, I get an
error saying 'the resource cannot be found'--it's looking for login.aspx.

I don't *have* this separate login page, nor would I like to get redirected
to a separate page for this. I want to use the same page, with *some*
controls showing, and an <asp:Login> control embedded into that if the user
isn't authenticated. Actually there's a couple of pages that I'd like to
have implemented in the same fashion--rendering a section of the page and an
<asp:Login> if appropriate...I don't want a generic login page.

Am I misinterpreting the form authentication/login mechanism? Do I really
have to have a dedicated login page, which every other page will redirect

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LoginView RolesGroup does not work Sharma ASP .Net 1 02-16-2009 03:33 PM
loginview in gridview not rebinding =?Utf-8?B?UGhpbA==?= ASP .Net 1 10-11-2006 12:06 PM
LoginView does not show a logged in user as being logged in keithb ASP .Net 0 02-16-2006 05:20 PM
Probably over my head... Trying to get Font Names Samantha Python 11 02-19-2005 05:12 PM
LoginView Type Control CJ Taylor ASP .Net 1 11-15-2004 04:39 PM