Updated : Simple ASP.Net Login Page

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 2
Reputation: ninimka is an unknown quantity at this point 
Solved Threads: 0
ninimka ninimka is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #11
Mar 28th, 2005
thnks a bunch 4 all ur good work paladine!!

it really works!

but since im a novice in asp.net, ive few question 4 u..

in ur application, evry succesfull login will be directed to default.aspx page..is there another way to direct to other page? the simple way is by renaming the file, but sure there is other way rite??

2ndly, i just wanted to clarify, by having form authorization, user cannot have access to any page in the web application rite?? but, unfortunately, it can happen in my application..i can still go directly to any page i desired by typing the path in the browser..whut is wrong?do i need to include some portion of code in every page in the application to indicate user must first log on?? im really newbie in asp.net..hope u cud help thnks!
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #12
Mar 28th, 2005
Thanks for the compliments!


To answer you second question first, I will say yes. Here is a synopsis of what you would have to do.

FormsAuthentication.RedirectFromLoginPage(username,createPersistentCookie)

Originally Posted by gotdotnet website_on_Security
when you pass FormsAuthentication.RedirectFromLoginPage a second parameter that equals false, like this: FormsAuthentication.RedirectFromLoginPage (UserName.Text, false)

RedirectFromLoginPage issues a temporary cookie, or session cookie, that expires when the browser is closed. If you pass true instead, RedirectFromLoginPage issues a persistent cookie thats good for 50 years.
You will want to modify this cookie, and you can check the cookie at the beginning of each page within the application and if it does not match you redirect to the login page. Hope that makes sense?

As for your second question, this is a setting under IIS, so simply go to the IIS managment console and modify the default page to whatever you like.

Hope this helps!

Take care

Originally Posted by ninimka
thnks a bunch 4 all ur good work paladine!!

it really works!

but since im a novice in asp.net, ive few question 4 u..

in ur application, evry succesfull login will be directed to default.aspx page..is there another way to direct to other page? the simple way is by renaming the file, but sure there is other way rite??

2ndly, i just wanted to clarify, by having form authorization, user cannot have access to any page in the web application rite?? but, unfortunately, it can happen in my application..i can still go directly to any page i desired by typing the path in the browser..whut is wrong?do i need to include some portion of code in every page in the application to indicate user must first log on?? im really newbie in asp.net..hope u cud help thnks!
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 5
Reputation: vbmntv is an unknown quantity at this point 
Solved Threads: 0
vbmntv vbmntv is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #13
Mar 28th, 2005
Thanks to Paladine - This is exactly what I am looking for and trying to do. I have a question - when I try to create procedure...it gives me an error - Server: Msg 170, Level 15, State 1, Procedure sp_ValidateUser, Line 8
Line 8: Incorrect syntax near 'Num_of_User'.
What does it mean? How to fix it. Thanks for a million.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 12
Reputation: Kendel is an unknown quantity at this point 
Solved Threads: 1
Kendel Kendel is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #14
Mar 28th, 2005
Hi there,

Thanks to Paladine, I've learned a lot from his .NET login example as well.

About the error, it's just a careless typo. To fix it, replace (.) with a commas(,) after NULL in the sencond line.

@UserName VARCHAR(50) = NULL,
@Password VARCHAR(50) = NULL,
@Num_of_User INT = 0


Originally Posted by vbmntv
Thanks to Paladine - This is exactly what I am looking for and trying to do. I have a question - when I try to create procedure...it gives me an error - Server: Msg 170, Level 15, State 1, Procedure sp_ValidateUser, Line 8
Line 8: Incorrect syntax near 'Num_of_User'.
What does it mean? How to fix it. Thanks for a million.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 2
Reputation: ninimka is an unknown quantity at this point 
Solved Threads: 0
ninimka ninimka is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #15
Mar 29th, 2005
Originally Posted by Paladine
You will want to modify this cookie, and you can check the cookie at the beginning of each page within the application and if it does not match you redirect to the login page. Hope that makes sense?
im so sorry 4 my low knowldge on this area, but cud u be more specific on this?? perhaps portion of coding to implement this?? thnks
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 5
Reputation: kantong is an unknown quantity at this point 
Solved Threads: 0
kantong kantong is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #16
Mar 29th, 2005
hi hi! thanks for the reply Paladine about the table issue. The next thing i want to do is compare a username to a username in the database.
From this line: FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
If i set to say: RedirectFromLoginPage(txtUserName.Text, True)
what does that do? and how can I compare this username in another page?
What I am trying to do is:
if the username = <temp username> then
load an empty form
else if username =<member's username> Then
Load form with member's details already there

im trying to create an update details page.
no idea how to access username thats being passed from the RedirectFromLoginPage...
cheers

Kevin
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 5
Reputation: vbmntv is an unknown quantity at this point 
Solved Threads: 0
vbmntv vbmntv is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #17
Mar 29th, 2005
Kendel, I saw that and I did change it with a commas(,) ...and got that error:
Server: Msg 170, Level 15, State 1, Procedure sp_ValidateUser, Line 8
Line 8: Incorrect syntax near 'Num_of_User'.

which is at this line: SET @ Num_of_User = (SELECT COUNT(*) AS Num_of_User

any ideas? Thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #18
Mar 29th, 2005
Ok, I will have to once again make this clear. *COPY & PASTE* only works well if you also understand the code. When I copy and paste the code I convert it with a vbColorCoder to have it look nice here. So sometimes extra spaces get added.

So in this case SET @ Num_of_User .... has a space between the @ and Num which it shouldn't, so please remove that and it should work.

So as I stated before, understanding the code and syntax is important!


Hope this helps!


Originally Posted by vbmntv
Kendel, I saw that and I did change it with a commas(,) ...and got that error:
Server: Msg 170, Level 15, State 1, Procedure sp_ValidateUser, Line 8
Line 8: Incorrect syntax near 'Num_of_User'.

which is at this line: SET @ Num_of_User = (SELECT COUNT(*) AS Num_of_User

any ideas? Thanks
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 5
Reputation: vbmntv is an unknown quantity at this point 
Solved Threads: 0
vbmntv vbmntv is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #19
Mar 29th, 2005
Thanks Paladine. I saw the extra space and fixed it. Thanks for the advice.
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

 
0
  #20
Mar 30th, 2005
No worries,

You can do something like this
Originally Posted by www.4guysfromrolla.com
Creating a Cookie with a custom Expiry Date
Alternatively you can create a cookie that's issued and has a custom lifetime instead of 50 years. The key is to replace the call to RedirectFromLoginPage method with the your own implementation, like so:
  Dim cookie As HttpCookie = FormsAuthentication.GetAuthCookie (UserName.Text, chkPersistCookie.Checked)
 ' Expires in 30 days, 12 hours and 30 minutes from today.
 cookie.Expires = DateTime.Now.Add(New TimeSpan(30, 12, 30, 0))
 Response.Cookies.Add (cookie)
 Response.Redirect (FormsAuthentication.GetRedirectUrl (UserName.Text,chkPersistCookie.Checked))
Originally Posted by www.4guysfromrolla.com
Here we have created a new authentication cookie, explicitly set its expiration date, added the cookie to the Cookies collection of the current HttpResponse instance, and finally we redirect the user to the page that they had requested.
Hope this helps
Originally Posted by ninimka
im so sorry 4 my low knowldge on this area, but cud u be more specific on this?? perhaps portion of coding to implement this?? thnks
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC