User controls and authentication problems...

D

David

Hi all,

An example layout of my page...


UC: Log Out linkbutton


PAGE:
Table
Row: UserName _______
Row: Password _______
Row: Logon Button


The idea is to show the Log Out linkbutton when the page is logged in and
the table is made invisible. I am using User.Identity.IsAthenticated to
manage making things visible or not...

The UC control actually verifies the logon account and password against the
database.


First come to page.

IsAuthenticated is false.
UC: is not visible
Table is visible

Enter username and password

Order of processing is:
PAGE: Page_Load
UC: Page_Load

This causes me an issue as I can get the Log Out button to show (as the UC
sets IsAuthenticated to true) but as the PAGE: Page_Load is prior to the UC:
verification, so the User/Pass table is still visible. I can't call the
table from the usercontrol as the control is held on many pages and not
every page has the username/password boxes.

The other side of the coin is also true. I click log out, the log out
disappears (as IsAuthenticated is false) but the table is not visible
(assuming I have done a refresh of the page to get the table to disappear)

Aaaarrrrgggghhhh!!!!! I have spent ages trying to make this work. I am soooo
frustrated. :-(

How can I get round it. The log out needs to be at the top of the page, the
UserName/Password boxes where the action is, so that people can quickly do
what they need to do that requires authentication.


Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
S

Stefan

I'm not sure if I got it right, but why don't you toggle the visibility
of your password controls in the PreRender event?

PreRender usually is an ideal place to do this kind of stuff, as there
could be still a lot of processing happening after the Load event (as
you experience), which changes the state of your page/model. The
UI/HTML that is posted back to the client browser in the http response
should represent the latest state of your session - changing these UI
properties in the load event is therefore usually a bit too early.
 

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,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top