Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Shaun 248 posts 475 karma points
    Nov 18, 2009 @ 15:44
    Shaun
    0

    Problems with redirecting using asp:login control

    Hi.

    I have an Umbraco 4 build that requires a login. On login I want to redirect the user to the homepage "/homepage.aspx".

    However, on logging in successfully, although the url in the bar changes to www.mysite/homepage.aspx the content of the homepage template does not appear in the page. Instead all I get is

    Welcome to xxx Intranet
    Please Login
    Welcome testuser Logout

    I've set up a member group called IntranetUsers and a member type called StandardUser (There will be other member types added later, this is just to test).

    I've created a user called testuser that is a member of the IntranetUsers group, however, I could see no method of setting the Member Type of that user to StandardUser.

    I've set my web.config to the following

     <!-- Membership Provider -->
        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="StandardUser" passwordFormat="Hashed" />
            <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
          </providers>
        </membership>

     

    Then I created a template and doctype for the homepage, and created a template and doctype for the login.

    The template for the login page is below.

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <title>Harlow Intranet - Login</title>
    </head>
    <body>
    <form id="login" runat="server">
    Welcome to HRL Client Intranet<br/>
    Please Login<br/>
    <asp:LoginView ID="UmbracoLoginView" runat="server">
        <AnonymousTemplate>
            <asp:Login ID="Login1" DisplayRememberMe="false" DestinationPageUrl="~/homepage.aspx" VisibleWhenLoggedIn="false" runat="server"></asp:Login>
        </AnonymousTemplate>
        <LoggedInTemplate>
            Welcome
            <asp:LoginName ID="LoginName1" runat="server" />
            <asp:LoginStatus ID="LoginStatus1" runat="server" />
        </LoggedInTemplate>
    </asp:LoginView>
    </form>
    </body>
    </html>
    </asp:Content>

     

    Can anyone tell me what I've done wrong? I'm new to the asp:loginview control, so I suspect its something pretty basic.

     

    Many thanks.

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 18, 2009 @ 16:11
    Dirk De Grave
    0

    Shaun,

     

    Don't see a problem with your code. For the sake of testing, could you move the Login control out of the Loginview control and see if it works then.

    If that is not working, you could still register for the LoggedIn event on the Login control and redirect in code.

     

    Hope this helps.

    Regards,

    /Dirk

  • Shaun 248 posts 475 karma points
    Nov 18, 2009 @ 16:28
    Shaun
    0

    Thanks Dirk

    I've removed the loginview control so I just have the login control on the page.

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <title>my website - Login</title>
    </head>
    <body>
    <form id="login" runat="server">
    Welcome to my extranet<br/>
    Please Login<br/>

    <asp:Login ID="Login1" DisplayRememberMe="false" DestinationPageUrl="/homepage.aspx" VisibleWhenLoggedIn="false" runat="server"></asp:Login>


    </form>
    </body>
    </html>
    </asp:Content>

    However,  I now only see the following

    Welcome to HRL Client Intranet
    Please Login

    with no login box associated with it. Having checked on the server I'm running asp.net 2.0. Could this be the cause of my problem?

    Thanks

    Shaun

  • Shaun 248 posts 475 karma points
    Nov 18, 2009 @ 16:29
    Shaun
    0

    hang, on, I've left out the form tag. oops

     

  • Shaun 248 posts 475 karma points
    Nov 18, 2009 @ 16:30
    Shaun
    0

    Ignore that last post. How do we delete posts on this thing anyway? :)

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 18, 2009 @ 16:39
    Dirk De Grave
    0

    Shaun,

    You have logged in before, right, to find out redirection is not working. If so, well, then remove the VisibleWhenLoggedIn="false", or if you'd like to start over, clear the authentication cookie (name of cookie can be found in web.config, it's yourAuthCookie for a default umbraco install)

     

    Hope this helps.

    Regards,

    /Dirk

  • Shaun 248 posts 475 karma points
    Nov 18, 2009 @ 16:43
    Shaun
    0

    aha, silly me. I've remove the VisibleWhenLoggedIn = false.

    I'm still getting the same behavior from it though. A correct url, but incorrect display.

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 18, 2009 @ 16:56
    Dirk De Grave
    0

    How's the content structured, ie, are those two pages (home and login) on the same level? in which order? 

    /Dirk

  • Shaun 248 posts 475 karma points
    Nov 18, 2009 @ 17:11
    Shaun
    0

    I've fathomed it out.

    My homepage had public access set to role based protection, with IntranetUsers set as the allowed roles.

    I had not set the testuser to be a member of the allowed group, so the site was correctly returning me to the login. However it was still displaying the url of the page my user would have visited, had he been a member of the correct group. Hence the confusion.

     

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies