Avatar of Wayne Atherton
Wayne Atherton
 asked on

Have a login control on the same Default.aspx page

Hi there,

i have a separate login page, which is working fine - When a user first visits my site, the Default.aspx is the home page, if the user isn't authenticated, then they are redirected to the login page, being redirected back to the Default.aspx page, when successfully authenticated.

I need to bring the login control into the Default.aspx page and make use of ASP:PAnel controls to hide certain portions of the page if the user isn't authenticated.

How do i configure the Web.Config file to do this?
.NET Programming

Avatar of undefined
Last Comment
Wayne Atherton

8/22/2022 - Mon
Wayne Atherton

ASKER
wakey wakey.....
Rose Babu

Hi,

Checking the login session and redirecting to login page is much simple to do.

in Default.aspx:

check the logged in user session variable e.g., session("UserName") which will be set in log in page. If the session("UserName") has value then you staty in Default.aspx else redirect it to login page.

in login page:

you can have a session variable e.g., session("UserName") to store successful logged in user details. on successful login you can store the username in the session. And then redirect to Default.aspx page. This will work.

And as you stated, you want to place the login control in the default page if the user has not authenticated. if so then why dont you add  a panel in default page and do the exact coding in the login control.

or else create the login page coding as a user control and make use of it wherever needed.
Wayne Atherton

ASKER
There needs to be only one page - Default.aspx.

In code behind I want to check User.Identity.IsAuthenticated. If true then hide the login panel and display main content. If false reverse panels, hiding the main content and displaying the login panel.

The method you've just posted is the traditional two page login that I'm not looking for.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Stephan

An addition to srosebabu's comment;
If you use formsauthentication you can check with "HttpContext.Current.User.Identity.IsAuthenticated"
Wayne Atherton

ASKER
Thanks Stephane, but this isn't what I was looking for. Read my last response.
Stephan

A bit too late with my post.

As you are saying you do a authentication check. What do you really want and why, because the post you just done gives what you need.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Stephan

If you want to hide man conten you can just wrap it with a placeholder, or maybe change masterpage in pageinit?
Wayne Atherton

ASKER
I still need to retain forms authentication, using the conventional web.config settings. However, when I set the login page to be Default.aspx the code behind works, but I get weird behaviour with both Update Panel and ScriptManager objects. Placing a breakpoint on Page Load in Visual Studio and walking through the identity check works fine, but Visual Studio then displays another tab stating that it can't find UpdatePanel.cs - commenting out my Update panel (which is part if the main part of the page) and running again, then the ScriptManager on my page does the same thing.
Wayne Atherton

ASKER
Not using master pages.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Stephan

How is the page set up? You say you use UpdatePanels?

Could you give me a markup code?
Wayne Atherton

ASKER
Source Not FoundDefault page
the second image is how i'm implementing the UpdatePanel and the ScriptManager.

and the first is what happens in Visual Studio:
ASKER CERTIFIED SOLUTION
Wayne Atherton

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Wayne Atherton

ASKER
Answered my own question
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.