473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Login Control in ASP.NET 2.0 and VS 2005

Hi,

I am trying to use the login control functionality on my website. I
have created this folder called Media which will contain the secured
pages of my site. I dragged a Login control on a register.aspx and
added the following code:

protected void Login1_Authenticate(object sender,
AuthenticateEventArgs e)
{
bool Authenticated = false;
Authenticated =
SiteLevelCustomAuthenticationMethod(Login1.UserNam e, Login1.Password);
e.Authenticated = Authenticated;
if (Authenticated == true)
{
Response.Redirect("~//Media//Media.aspx");
}
}
private bool SiteLevelCustomAuthenticationMethod(string username,
string password)
{
bool boolReturnValue = false;
if (username.ToLower().Equals("me") &&
password.ToLower().Equals("abc123"))
boolReturnValue = true;
return boolReturnValue;
}

(Of course I will change the code in
SiteLevelCustomAuthenticationMethod to either connect to database, or
read an xml file and match username password. )

This worked but the problem I was having was that the users could still
browse to "Media/Media.aspx" manually and it would allow them. I then
added the following to my web.config:

<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true"/>
<authorization>
<allow users="*"/>
</authorization>
<authentication mode="Forms">
<forms name=".ASPXAUTH"
loginUrl="RegisterLogin.aspx"
protection="Validation"
timeout="999999"/>
</authentication>
</system.web>
<location path="Media">
<system.web>
<compilation debug="true"/>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>

Now when I did this, it stopped anyone from directly browsing to the
Media.aspx, but it also stopped the authenticated user (me, abc123)
from logging in and it kept throwing him back to the register.aspx.

I figured this is happening because the user isn't really authenticated
i.e. Context.User.Identity.IsAuthenticated is false. So I don't know
what to do to actually authenticate the user? It's almost as if the
link between my authentication method above and the web.config file is
broken. What am I missing? What do I need to do more?

p.s.: I have no idea what this is "<forms name=".ASPXAUTH"". I didn't
know what else to use as I am using master pages, and really have only
one form in my master page. So I just put this name there. Didn't seem
to be doing anything drastic.

Asad

Jun 15 '06 #1
0 974

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: XP | last post by:
I am having problems with the blow page. I have a login page where I enter the userid and password. This then connects to this page. If I enter the userid and password correctly, it prints...
14
by: clintonG | last post by:
This is an appeal for peer support sent to Microsoft as will be noted in closing. The Login control does not include a Cancel button. The only option is to convert the Login control to a...
6
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
7
by: RedEye | last post by:
Hello, Here is the problem. I have two sites both of which use the asp.net v2 login controls. Both sites are coded identicaly including the config file. There is only one thing that is...
4
by: windle.johnson | last post by:
I have dropped the 2005 login control on my page and set up a user in the development enviroment using the administration tool that comes with 2005. I have now deployed the website and I need to...
2
by: John | last post by:
Hi I am using login control with sql server based membership/roles. I have checked the 'remember me' tick box but the login control does not show the username/password when I next come back to...
5
by: Seok Bee | last post by:
Dear Experts, I an trying to use the Login controls in asp.net 2.0 in the Visual Studio 2005. I have created the login page as login.aspx and set the DestinationPageUrl to ont of my webpage. I...
5
by: Kivak Wolf | last post by:
Hi, I am currently trying to make a website that requires an account to use so it can disply the data according to the account. I have ASP.NET 2.0 installed and working fine. However, it is not...
2
by: Sasquatch | last post by:
I'm having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight forward,...
2
by: Sasquatch | last post by:
I'm still having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.