.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old March 26th, 2008, 12:28 PM
iis_guy iis_guy is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 145 iis_guy User rank is Corporal (100 - 500 Reputation Level)iis_guy User rank is Corporal (100 - 500 Reputation Level)iis_guy User rank is Corporal (100 - 500 Reputation Level)iis_guy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 15 h 16 m 7 sec
Reputation Power: 3
FormsAuthentication?

Hello all.

What is the advantage/disadvantage of using FormsAuthentication.RedirectFromLoginPage

E.g. What is the different between the following:
Code:
if( IsUserAuthenticated(txtUser, txtPassword) )
{
    // Create the authetication ticket

    FormsAuthenticationTicket authTicket new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(60), False , groups);

    // Now encrypt the ticket.
    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

    // Create a cookie and add the encrypted ticket to the cookie as data.
    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

    // Add the cookie to the outgoing cookies collection.
    Response.Cookies.Add(authCookie);

    // Redirect the user to the originally requested page
    Response.Redirect(FormsAuthentication.GetRedirectU  rl(txtUserName.Text,false));
}


Versus this:
Code:
if( IsUserAuthenticated(txtUser, txtPassword) )
{
    FormsAuthentication.RedirectFromLoginPage(txtUser.  Text, false);
}

Does the 2nd parameter of RedirectFromLoginPage do all the dirty work of creating the cookie for us?

Thanks for any insight into this

Reply With Quote
  #2  
Old March 26th, 2008, 12:38 PM
jmurrayhead's Avatar
jmurrayhead jmurrayhead is offline
The Drunken Moderator
Click here for more information.
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 12,940 jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 76927 Folding Title: Intermediate FolderFolding Points: 76927 Folding Title: Intermediate FolderFolding Points: 76927 Folding Title: Intermediate FolderFolding Points: 76927 Folding Title: Intermediate Folder
Time spent in forums: 3 Months 2 Days 19 h 31 m 55 sec
Reputation Power: 1456
Facebook
The second parameter simply states that the cookie will or will not be persistent. If set to True, then the cookie will be left on the user's machine even after the session times out or they close the browser. If they were to come back, they would still be logged in. On many login forms, you will see a checkbox stating "Remember Me". That's what the second parameter does. If you were to have a 'remember me' checkbox on your login form, you could pass that checkbox value to the function like so:

Code:
FormsAuthentication.RedirectFromLoginPage(txtUser.    Text, Checkbox1.Checked);


The advantage of the second code snippet is that it is faster, but I suppose the advantage of the first code snippet is that you could further customize what you want to happen when a user logs in.
__________________
jmurrayhead

Did I help you out? Make me popular by clicking the icon!

New Members:Proper way to post a question

Powered by ASP.Net

Reply With Quote
  #3  
Old March 26th, 2008, 03:11 PM
iis_guy iis_guy is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 145 iis_guy User rank is Corporal (100 - 500 Reputation Level)iis_guy User rank is Corporal (100 - 500 Reputation Level)iis_guy User rank is Corporal (100 - 500 Reputation Level)iis_guy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 15 h 16 m 7 sec
Reputation Power: 3
Thanks for the reply jmurrayhead.

So by using the 2nd method, does it implicity do the things that the first method does? (i.e. create an encrypted cookie?)

My concern is that the 2nd method does not do any encryption, leaving the authentication information exposed someplace

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > FormsAuthentication?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway