Forms Authentication

Results 1 to 2 of 2

Thread: Forms Authentication

  1. #1
    Join Date
    Dec 1969

    Default Forms Authentication

    In classic ASP, I had an include file containing an authentication script, and a login page which could be displayed instead of the requested page. This was included in all pages requiring verification and any posted form fields were persisted as hidden fields, as was the querystring. In this way, if a user timed out, it would just be a matter of entering their password again, and they could carry on from where they left off, on the appropriate page.<BR><BR>Is there an easy way of doing this in ASP.NET? I don&#039;t want to have to repeat code, but I need to be able to provide two different outcomes depending on login state.<BR><BR>Sorry, I&#039;m a bit of a Newbie with this.

  2. #2
    Join Date
    Dec 1969

    Default RE: Forms Authentication

    If you use true forms authentication, this is very easy. You basically specify a login page in your web.config file and the user is automatically redirected to this page if their session times out.<BR><BR>After they log in, you can redirect the user back to the page they first tried to reach.<BR><BR>In your web.config file: <BR>&#060;authentication mode="Forms" &#062;<BR> &#060;forms name=".MyApplication" loginUrl="Login.aspx" protection="All" timeout="20" path="/" /&#062;<BR>&#060;/authentication&#062;<BR><BR><BR>In your code, you need to manually authenticate your users and<BR><BR>&#039; --------------------------------------------------<BR><BR>Imports System.Web.Security<BR><BR>If TheUserIsValidated() Then<BR> FormsAuthentication.SetAuthCookie(MyLoginID, True)<BR> Response.Redirect(Request.QueryString("ReturnURL") )<BR>Else<BR> lblFormMsg.Text = "Sorry, the username or password was invalid. Please try again."<BR>End If<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts