| | |
Updated : Simple ASP.Net Login Page
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 2
Reputation:
Solved Threads: 0
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!
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!
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)
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
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.
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!
•
•
Join Date: Mar 2005
Posts: 5
Reputation:
Solved Threads: 0
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.
Line 8: Incorrect syntax near 'Num_of_User'.
What does it mean? How to fix it. Thanks for a million.
•
•
Join Date: Feb 2005
Posts: 12
Reputation:
Solved Threads: 1
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
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.
•
•
Join Date: Mar 2005
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
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?
•
•
Join Date: Mar 2005
Posts: 5
Reputation:
Solved Threads: 0
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
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
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!
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
No worries,
You can do something like this
Hope this helps
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.
•
•
•
•
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
![]() |
Similar Threads
Other Threads in the ASP.NET Forum
- Previous Thread: Login view
- Next Thread: Problem iterating through code to show sales tax
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





