User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,667 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,926 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 198 | Replies: 1 | Solved
Reply
Join Date: Sep 2006
Posts: 104
Reputation: bhavna_816 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

Authorizaton in ASP.NET 2.0

  #1  
May 26th, 2008
I have a login page where I have my own label and texboxes which take input username and password, and there is a function in which there is a SP which validates username and password stored in the database.

My code in Login.aspx.cs is such that I call that function and validates username and password and redirects to next page Page2.aspx.

Now I want my site to be authorized such that if a user tries to access internal pages he couldn't be able to do that.

I have code in my WEb.config for that is
		<authentication mode="Forms">

			<forms cookieless="UseCookies" timeout="525600" />
		</authentication>
		<authorization>

			<deny users="?" />
			<allow users="*" />
		</authorization>

and code in login.aspx.cs is

protected void btnLogin_Click(object sender, EventArgs e)
{
validateUser = validateUser.ValidateUser(txtUserName.Text, hashedPassword);

if (Page.IsValid)
			{
				if (validateUser != null)
				{

					

						Response.Redirect("~/Page2.aspx");
				
					
				}
				else
				{
					lblErrorMessage.Text = "Invalid User";
				}
			}
}
Now when I try to run internal pages without login it automatically redirects to login page which is fine but when I put valid username and password in the login page it redirects with some "ReturnUrl" and not able to redirect to the Page2.aspx page.This is my problem.
Can anybody tell me where I am doing wrong or need to change the code somewhere?
Thanks in advance,
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 287
Reputation: ericstenson is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: Authorizaton in ASP.NET 2.0

  #2  
May 26th, 2008
Yes, your problem is that you are over complicating the problem.
--
"Dummy."
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 1:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC