471,571 Members | 1,020 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,571 software developers and data experts.

OnAuthenticate Event, Login Controls

pj

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="javascript:popup('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>

Nov 16 '06 #1
1 6333
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" <pj****@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr 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="javascript:popup('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>

Nov 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Robert Rolls | last post: by
5 posts views Thread by Seok Bee | last post: by
1 post views Thread by Roman | last post: by
8 posts views Thread by Brad Isaacs | last post: by
1 post views Thread by Vince | last post: by
4 posts views Thread by shilpareddy2787 | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.