Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > OnAuthenticate Event, Login Controls

Reply
Thread Tools

OnAuthenticate Event, Login Controls

 
 
pj
Guest
Posts: n/a
 
      11-16-2006

I'm trying to redirect users to another page after they Authenticate
with the ASP.NET login controls. The user is able to login, but I
can't get the response.redirect to work. Can anyone help?

My code is below.

Thanks,

pj
mcdba, mcp


<%@ Page language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<%@ Import Namespace="System.Web.UI.Page" %>
<%@ Import Namespace="System.Web.HttpServerUtility" %>

<script language="VB" runat="server">
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
' Response.Redirect("home.aspx")
End Sub

Function SiteSpecificAuthenticationMethod(ByVal UserName As String,
ByVal Password As String) As Boolean
' Insert code that implements a site-specific custom
' authentication method here.
'
Response.Redirect("home.aspx")
' This example implementation always returns false.
Return False
End Function

Sub OnAuthenticate(ByVal sender As Object, ByVal e As
AuthenticateEventArgs)
Dim Authenticated As Boolean
Dim Login1 As Login
Authenticated =
SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)

e.Authenticated = True
End Sub



</script>


<script type="text/javascript">
function popup(url){var
mypopup=window.open(url,"","width=400,height=300,t op=80,left=100,status,scrollbars")}
</script>



<div align="center">
<form runat="server" id="form1">
<asp:LoginView ID="LoginView1" runat="server">


<AnonymousTemplate>

<asp:Login ID="Login1" runat="server"
CreateUserText="Create Consumer Account"
CreateUserUrl="jk1register.aspx"
Orientation="Vertical" RememberMeSet="true"
onauthenicate="OnAuthenticate">
<LayoutTemplate>

<table border="0" width="100%" id="table136" cellpadding="0"
cellspacing="1">
<tr>
<td bgcolor="#DEE8ED" class="sidenavtitle">
<div align="center">
JK1 Account Login&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style="font-weight: 400">
<a href="bthiacctmngmnt/jk1register.aspx">Register for an
account</a></span></div>
</td>
</tr>
<tr>
<td>
<table class="sidenavcontent" cellPadding="0" border="0" id="table145">
<tr>
<td height="10">
<label id="LoginView1_Login1_UserNameLabel"
for="LoginView1_Login1_UserName">Login</label>
<br/>

<asp:TextBox ID="UserName" runat="server" style="WIDTH:
80px"></asp:TextBox><asp:RequiredFieldValidator ID="UserNameRequired"
runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is
required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>

</td><td>
<label id="LoginView1_Login1_PasswordLabel"
for="LoginView1_Login1_Password">Password
<br/>

</label>
<asp:TextBox ID="Password" runat="server" TextMode="Password"
style="WIDTH: 80px"></asp:TextBox><asp:RequiredFieldValidator
ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is required." ToolTip="Password is
required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
<td valign="bottom">
<asp:ImageButton ID="LoginImageButton" runat="server"
AlternateText="Log In" CommandName="Login" width="61" height="22"

ImageUrl="~/images/submitbutton.gif" ValidationGroup="Login1" />
</td>
</tr>
<tr height="30">
<td colspan="3">
<a href="javascriptopup('jk1forgotpassword.aspx')"> Forgot Login
or Password?</a>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red">
<asp:Literal ID="FailureText" runat="server"
EnableViewState="False"></asp:Literal>
</td>
</tr>

</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>

</AnonymousTemplate>
<LoggedInTemplate>
<table border="0" class="sidenavcontent" cellpadding="0"
cellspacing="1" id="table1">
<tr>
<td align="left" class="sidenavtitle" bgcolor="#DEE8ED">
<a href="bthiacctmngmnt/home.aspx">JK1 Account
Management</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
<span style="font-weight: 400">
<asp:LoginStatus FormatString="JK1 Account Login"
ID="LoginStatus1" runat="server"/>
</span>
</td>
</tr>
<tr>
<td align="center">
<asp:LoginName FormatString="{0}, welcome to JK1.com!"
runat="server"></asp:LoginName>
</td>
</tr>
</table>
</LoggedInTemplate>

</asp:LoginView>
</form>
</div>

 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      11-16-2006
You should be able to call SetAuthCookie and then do a regular
Response.Redirect to wherever you'd like.
Here's more information:
http://authors.aspalliance.com/aspxt...uthCookie.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net


"pj" <> wrote in message
news: oups.com...
>
> I'm trying to redirect users to another page after they Authenticate
> with the ASP.NET login controls. The user is able to login, but I
> can't get the response.redirect to work. Can anyone help?
>
> My code is below.
>
> Thanks,
>
> pj
> mcdba, mcp
>
>
> <%@ Page language="VB" Debug="true" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SQLClient" %>
> <%@ Import Namespace="System.Web.UI.Page" %>
> <%@ Import Namespace="System.Web.HttpServerUtility" %>
>
> <script language="VB" runat="server">
> Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
> ' Response.Redirect("home.aspx")
> End Sub
>
> Function SiteSpecificAuthenticationMethod(ByVal UserName As String,
> ByVal Password As String) As Boolean
> ' Insert code that implements a site-specific custom
> ' authentication method here.
> '
> Response.Redirect("home.aspx")
> ' This example implementation always returns false.
> Return False
> End Function
>
> Sub OnAuthenticate(ByVal sender As Object, ByVal e As
> AuthenticateEventArgs)
> Dim Authenticated As Boolean
> Dim Login1 As Login
> Authenticated =
> SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)
>
> e.Authenticated = True
> End Sub
>
>
>
> </script>
>
>
> <script type="text/javascript">
> function popup(url){var
> mypopup=window.open(url,"","width=400,height=300,t op=80,left=100,status,scrollbars")}
> </script>
>
>
>
> <div align="center">
> <form runat="server" id="form1">
> <asp:LoginView ID="LoginView1" runat="server">
>
>
> <AnonymousTemplate>
>
> <asp:Login ID="Login1" runat="server"
> CreateUserText="Create Consumer Account"
> CreateUserUrl="jk1register.aspx"
> Orientation="Vertical" RememberMeSet="true"
> onauthenicate="OnAuthenticate">
> <LayoutTemplate>
>
> <table border="0" width="100%" id="table136" cellpadding="0"
> cellspacing="1">
> <tr>
> <td bgcolor="#DEE8ED" class="sidenavtitle">
> <div align="center">
> JK1 Account Login&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> <span style="font-weight: 400">
> <a href="bthiacctmngmnt/jk1register.aspx">Register for an
> account</a></span></div>
> </td>
> </tr>
> <tr>
> <td>
> <table class="sidenavcontent" cellPadding="0" border="0" id="table145">
> <tr>
> <td height="10">
> <label id="LoginView1_Login1_UserNameLabel"
> for="LoginView1_Login1_UserName">Login</label>
> <br/>
>
> <asp:TextBox ID="UserName" runat="server" style="WIDTH:
> 80px"></asp:TextBox><asp:RequiredFieldValidator ID="UserNameRequired"
> runat="server" ControlToValidate="UserName"
> ErrorMessage="User Name is required." ToolTip="User Name is
> required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
>
> </td><td>
> <label id="LoginView1_Login1_PasswordLabel"
> for="LoginView1_Login1_Password">Password
> <br/>
>
> </label>
> <asp:TextBox ID="Password" runat="server" TextMode="Password"
> style="WIDTH: 80px"></asp:TextBox><asp:RequiredFieldValidator
> ID="PasswordRequired" runat="server" ControlToValidate="Password"
> ErrorMessage="Password is required." ToolTip="Password is
> required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
> </td>
> <td valign="bottom">
> <asp:ImageButton ID="LoginImageButton" runat="server"
> AlternateText="Log In" CommandName="Login" width="61" height="22"
>
> ImageUrl="~/images/submitbutton.gif" ValidationGroup="Login1" />
> </td>
> </tr>
> <tr height="30">
> <td colspan="3">
> <a href="javascriptopup('jk1forgotpassword.aspx')"> Forgot Login
> or Password?</a>
> </td>
> </tr>
> <tr>
> <td align="center" colspan="2" style="color: red">
> <asp:Literal ID="FailureText" runat="server"
> EnableViewState="False"></asp:Literal>
> </td>
> </tr>
>
> </table>
> </td>
> </tr>
> </table>
> </LayoutTemplate>
> </asp:Login>
>
> </AnonymousTemplate>
> <LoggedInTemplate>
> <table border="0" class="sidenavcontent" cellpadding="0"
> cellspacing="1" id="table1">
> <tr>
> <td align="left" class="sidenavtitle" bgcolor="#DEE8ED">
> <a href="bthiacctmngmnt/home.aspx">JK1 Account
> Management</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
> <span style="font-weight: 400">
> <asp:LoginStatus FormatString="JK1 Account Login"
> ID="LoginStatus1" runat="server"/>
> </span>
> </td>
> </tr>
> <tr>
> <td align="center">
> <asp:LoginName FormatString="{0}, welcome to JK1.com!"
> runat="server"></asp:LoginName>
> </td>
> </tr>
> </table>
> </LoggedInTemplate>
>
> </asp:LoginView>
> </form>
> </div>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Membership.ValidateUser() from Login.OnAuthenticate()? asnowfall@gmail.com ASP .Net Security 2 01-16-2008 05:18 PM
Membership.ValidateUser() from Login.OnAuthenticate()? asnowfall@gmail.com ASP .Net 0 01-15-2008 07:16 PM
New ASP.NET 2.0 Login control: handling OnAuthenticate event natasha ASP .Net Web Controls 0 11-21-2006 09:12 AM
Login Controls - Force user to change password at next login pj ASP .Net 2 10-31-2006 12:16 AM
HttpModule - OnAuthenticate event Robert Rolls ASP .Net 0 06-21-2005 10:45 AM



Advertisments