Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2008, 02:25 PM
Authorized User
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login page problem

Following along with Marco Bellinaso's ASP.NET 2.0 Website Programming, I've reached Chapter 4, where Membership and User Profiling is created for the sample site.

For the authentication, I've used the following web.config commands:

<authentication mode="Forms">
      <forms cookieless="AutoDetect" loginUrl="~/AccessDenied.aspx" name="TBHFORMAUTH" />
    </authentication>

I have the login box on my master file so all pages have an instance of the login box. The problem is, when a user logs in with invalid credentials, the page they logged in from is refreshed, and no redirect to ~/AccessDenied.aspx happens.

I'm not sure what the problem is here. Anyone have an idea?
 
Old November 18th, 2008, 03:23 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Do you have the Login button set with CommandName="Login" ?

Visit my blog at http://leedumond.com
 
Old November 18th, 2008, 04:06 PM
Authorized User
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Login button does have the CommandName="Login"

Here is the code from Template.master (with HTML formatting removed):

Code:
<asp:LoginView ID="LoginView1" runat="server">
    <AnonymousTemplate>
        <asp:Login ID="Login" runat="server" Width="100%">
            <LayoutTemplate>
                Username:
               <asp:TextBox ID="UserName" runat="server" Width="95%"></asp:TextBox>
               <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." SetFocusOnError="true" ValidationGroup="Login" Text="*" />
                Password:
                <asp:TextBox ID="Password" runat="server" TextMode="Password" Width="95%"></asp:TextBox>
                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="Login" Text="*" />
                <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me" />
                <asp:ImageButton ID="Submit" runat="server" CommandName="Login" ImageUrl="~/images/go.gif"
ValidationGroup="Login" />   
            </LayoutTemplate>
        </asp:Login>
    </AnonymousTemplate>
    <LoggedInTemplate>

    </LoggedInTemplate>
</asp:LoginView>
 
Old November 18th, 2008, 04:07 PM
Authorized User
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also, a successful login works just fine. It's only when I enter invalid credentials do I not get the expected redirect.
 
Old November 18th, 2008, 04:55 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

In the <asp:Login> tag, you are missing an important attribute.

<asp:Login ID="Login" runat="server" Width="100%" FailureAction="RedirectToLoginPage">

_________________________________

Visit my blog at http://leedumond.com
 
Old November 18th, 2008, 05:25 PM
Authorized User
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Adding the FailureAction="RedirectToLoginPage" fixed the problem. Thanks Lee!





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in designing login page like orkut nirmalbarsainyan ASP.NET 1.x and 2.0 Application Design 1 April 19th, 2007 05:15 AM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 07:09 PM
LOGIN PAGE (does not link to the next page) [email protected] Classic ASP Databases 7 April 5th, 2006 01:28 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.