Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 18th, 2008, 02:25 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
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?
  #2 (permalink)  
Old November 18th, 2008, 03:23 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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
  #3 (permalink)  
Old November 18th, 2008, 04:06 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
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>
  #4 (permalink)  
Old November 18th, 2008, 04:07 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
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.
  #5 (permalink)  
Old November 18th, 2008, 04:55 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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
  #6 (permalink)  
Old November 18th, 2008, 05:25 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 06:15 AM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 08:09 PM
LOGIN PAGE (does not link to the next page) jim.sullivan@telus.net Classic ASP Databases 7 April 5th, 2006 02:28 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 08:47 AM



All times are GMT -4. The time now is 02:50 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.