Copied to clipboard

Flag this post as spam?

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


  • Dan Christoffersen 64 posts 119 karma points
    Sep 19, 2009 @ 17:34
    Dan Christoffersen
    0

    Member login won't work

    I'm getting pretty frustrated getting the Member Login to work.

    Everything seems to work, but the user is not registered as logged in (isLoggedOn=False).

    It seems like the login control recognises the logon information, making no error message when the correct username and password is entered (and giving an error if they are wrong).

    I have been looking through the forum and the wiki, and tried a million different approached, all with the same result.

    Please, if anyone have any clue what I am doing wrong, I will really appreaciate it.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 20, 2009 @ 08:48
    Aaron Powell
    1

    Can you please provide some more information such as:

    - Umbraco Version

    - Where 'isLoggedOn' is being read from

    - Which login control are you using

  • Dan Christoffersen 64 posts 119 karma points
    Sep 20, 2009 @ 10:49
    Dan Christoffersen
    0

    Of course - sorry for the lack of information - I was REALLY frustrated when i wrote that ;-)

    Umbraco version: 4.0.2.1

    I have written a usercontrol which is place on every page that checks if the user is logged on or not. Currently, all it does is just to write true if logged on and false if not.

    Since my last post i have noticed that when I log on, I am redirected to the front page. Here the isLoggedOn is true, and stays true event if I refresh the page (using ctrl+r). But if I click on the link in the menu for the front page (or any other page), the control returns false again.

    I have been using both a self made login control:

    Member currentUser = Member.GetMemberFromLoginNameAndPassword(TextBox1.Text, TextBox2.Text);
    if (currentUser != null)
    {
    if (UseCookiesForAuthentication)
    Member.AddMemberToCache(currentUser);
    else
    Member.AddMemberToCache(currentUser, true, new TimeSpan(0, 0, 0));
    }

    and the default asp.net login control, and event the macros in Niels Hartvigs MemberControl package. All with the same result - neither works.

    The code for the usercontrol that i have placed on every page:

            protected void Page_Load(object sender, EventArgs e)
    {
    Content.Text = umbraco.library.IsLoggedOn().ToString();
    }

    I have also tried to use the Member.isLoggedOn() with no luck.

    Maybe it has something to do with the IIS website setup? The project was initially installed on my local computer and then uploaded to a hosted webserver. I can only get to the IIS manager from work, so I have not been able to play around with the settings there. Maybe app pool restart would do the job?

    If you want to test yourself, here is the link to the login page: alpha dot firmafisk dot dk/brugerkonto    (change the dot to .)
    You can use this to login: user: [email protected]  psw: 1234

    Hope this information can help someone identify the problem. If not, please don't hesitate to ask.

    /Dan

  • Dan Christoffersen 64 posts 119 karma points
    Sep 20, 2009 @ 10:53
    Dan Christoffersen
    0

    Forgot to mention that I have also tried System.Web.Security.Membership.GetUser()  which returns null and Membership.GetNumberOfUsersOnline().ToString() which returns 0 (zero).

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 20, 2009 @ 14:41
    Aaron Powell
    0

    Directly interacting with the membership API is no longer recommended due to the move to the ASP.NET membership provider model. There was a problem if you were storing members in Session in v3, but I think that was only with signing them out.

    Check out this wiki page, it'll cover all that you should need to for doing membership stuff - http://our.umbraco.org/wiki/how-tos/membership-providers

    Personally I recommend just using the standard ASP.NET login control, I put together a small demo site using them (for a blog I did about the membership profile provider) which I may have the code still for, I'll check tomorrow for you.

  • Dan Christoffersen 64 posts 119 karma points
    Sep 20, 2009 @ 15:25
    Dan Christoffersen
    0

    I have located the problem!

    I have been using umbracoUseDirectoryUrls = true which I would love to go back to. But setting this to default (false) fixes the problem and the login works fine.

    For now, I'll just keep the ugly .aspx urls, but if anyone knows how to get this to work with directoryUrls, I would highly appreciate the help.

    Anyway, thank you for your help so far Slace.

    Enjoy the rest of the weekend - finally, I can ;-)

  • Dan Christoffersen 64 posts 119 karma points
    Sep 21, 2009 @ 22:00
    Dan Christoffersen
    1

    Just noticed that there is still a problem with the front page which is just the domain url (www.firmafisk.dk) and does not have the aspx extension. On the front page, the login status is then "not logged in" and on all other pages (with the aspx extension) the user is still logged on.

    I find this very strange - maybe it is a IIS setting? Any ideas?

  • Thomas Kahn 602 posts 506 karma points
    Jan 05, 2010 @ 14:15
    Thomas Kahn
    0

    Aha! I would NEVER have figured that one out myself!

    I have the exact same problem. When directory URL's are used, nothing works - it's like the user isn't logged in. Turning directory URL's off, everything but the first page works, just like in your case.

    It looks like I'm going to have to use the standard ASP.NET login control, but I'm not sure if it's flexible enough.

    Thanks Dan for documenting this problem! Thumbs up for that!

    /Thomas Kahn

  • Thomas Kahn 602 posts 506 karma points
    Jan 07, 2010 @ 11:33
    Thomas Kahn
    0

    And now when I have switched to plain ASP.NET controls added to usercontrols and have directory URL's set to true, I still get the same errors. Setting directory URL's to false and everything works like a charm.

    It looks like a bug, but I'm not sure?

    /Thomas

  • Thomas Kahn 602 posts 506 karma points
    Jan 07, 2010 @ 11:49
    Thomas Kahn
    1

    I found a solution to the problem on codeplex:

    http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=22929&ProjectName=umbraco&PendingVoteId=22929

    If you follow these instructions:

    Default behaviour for iis7 for the formsauthentication module is to only invoke for requests to asp.net applications or managed handlers (probably also for iis6). If you disable the 'Invoke only for requests to ASP.NET applications or managed handlers' option, forms authentication will work then also for directory urls.

    ...it will work. I'm running IIS7 and this is how I altered the settings:

    1. Open up IIS Manager
    2. Select the website you want to alter
    3. Double click on "Modules"
    4. Locate the parameter named "FormsAuthentication" and double click on it
    5. Uncheck the checkbox "Invoke only for requests to ASP.NET applications or managed handlers"
    6. Click OK

    It looks like it adds the following lines to the web.config:

    <remove name="FormsAuthentication" />
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="" />

    After having done this adjustment, logging in and out and displaying the correct login status works again!

    /Thomas Kahn

  • Thomas Kahn 602 posts 506 karma points
    Jan 07, 2010 @ 12:01
    Thomas Kahn
    0

    One thing that still doesn't work though is if you have directory url's set to true and try to access a protected page and you are not logged in. Then you get the following error:

    [NullReferenceException: Object reference not set to an instance of an object.]
    System.Web.Security.Membership.GetCurrentUserName() +37
    System.Web.Security.Membership.GetUser() +7
    umbraco.requestHandler..ctor(XmlDocument _umbracoContent, String url) +3493
    umbraco.UmbracoDefault.Page_PreInit(Object sender, EventArgs e) +903
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.EventHandler.Invoke(Object sender, EventArgs e) +0
    System.Web.UI.Page.OnPreInit(EventArgs e) +8699406
    System.Web.UI.Page.PerformPreInit() +31
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282

    Setting directory url's to false makes things work again.

    /Thomas

  • Thomas Kahn 602 posts 506 karma points
    Jan 07, 2010 @ 12:08
    Thomas Kahn
    3

    Then, if you follow the other advice on the codeplex page; adding an attribute to the modules tag in web.config:

    <modules runAllManagedModulesForAllRequests="true">

    ...then you get rid of the problem that occurs if you try to access a protected page while not being logged in (with directory url's set to true).

    A follow-up question: are there any other implications when doing the above alteration? I'm not very good at web servers, but could this compromise security? Will ISP's allow this modification?

    /Thomas K

  • Lee 1130 posts 3088 karma points
    Jan 07, 2010 @ 12:11
    Lee
    0

    Ahhhh I'm having this problem... Moved a site from IIS6 to IIS7

    http://our.umbraco.org/forum/getting-started/installing-umbraco/6262-Admin-Password-Moved-Umbraco-Site

    @Thomas - So will this solve my problem when logged in?

    <modules runAllManagedModulesForAllRequests="true">

  • Lee 1130 posts 3088 karma points
    Jan 07, 2010 @ 12:15
    Lee
    0

    Just to let you know adding 

    <modules runAllManagedModulesForAllRequests="true">

    Solved my problem on the site :)

  • Thomas Kahn 602 posts 506 karma points
    Jan 07, 2010 @ 12:51
    Thomas Kahn
    1

    Here's an article that describes the problem a little more in detail:

    http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/

    /Thomas

  • Daniel Lindstrom 454 posts 271 karma points
    Mar 02, 2010 @ 17:19
    Daniel Lindstrom
    0

    Had the exaxt same problem. Thanks for sharing the solution. Thumbs up!

  • Christian Palm 277 posts 272 karma points
    Sep 20, 2010 @ 15:01
    Christian Palm
    0

    Great. Works for me to.

  • Alexander Bryukhov 19 posts 68 karma points c-trib
    Oct 19, 2010 @ 09:56
    Alexander Bryukhov
    0

    Thanks, Thomas!

    Your solutions are work for my latest project hosted on IIS7 :-)

Please Sign in or register to post replies

Write your reply to:

Draft