Copied to clipboard

Flag this post as spam?

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


  • Natalia Langa 12 posts 31 karma points
    Jun 04, 2012 @ 09:07
    Natalia Langa
    0

    How to use umbraco membership provider in non-umbraco .NET MVC application?

    Hi!

    Can anyone tell me how can I user umbraco membership provider in other, non-umbraco .NET MVC project?

    I have an Umbraco site and I've written a subapplication in standard .NET MVC in which I would like to user the same users from Umbraco site. I added UmbracoMembershipProvider to web.config and imported:

    • busineslogic.dll
    • cms.dll
    • interfaces.dll
    • umbraco.dll
    • umbraco.providers.dll
    I don't want to create new members, just user login page with umbraco user credentials.
    When I try to login in I get an error:
    Message: "Object reference not set to an instance of an object."
    Source: "cms"
    StackTrace: "   at umbraco.cms.businesslogic.member.Member.GetMemberFromLoginAndEncodedPassword(String loginName, String password)\r\n   at umbraco.providers.members.UmbracoMembershipProvider.ValidateUser(String username, String password)\r\n   at PyreePollsWeb.Controllers.AdminController.LogOn(FormCollection formCollection, String returnUrl) in D:\\pyree.pl\\SourceCode\\PyreePollsWeb\\Controllers\\AdminController.cs:line 91"
    Do you know what am I doing wrong?
    Thank you for your help!

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 04, 2012 @ 10:27
    Michael Latouche
    0

    Hi Natalia,

    When adding the UmbracoMembershipProvider in your web.config, did you also add the "Umbraco specific" attributes, like MemberTypeAlias?

    Cheers,

    Michael.

  • Natalia Langa 12 posts 31 karma points
    Jun 04, 2012 @ 10:30
    Natalia Langa
    0

    Hi,

    Thanks for your reply.

    My membership section in web.config looks like this:

    <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="UmbracoMembershipProvider"
                 type="umbraco.providers.members.UmbracoMembershipProvider"
                 enablePasswordRetrieval="false"
                 enablePasswordReset="false"
                 requiresQuestionAndAnswer="false"
                 defaultMemberTypeAlias="Another Type"
                 passwordFormat="Hashed" />
          </providers>
        </membership>
  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 04, 2012 @ 11:38
    Michael Latouche
    0

    Hi Natalia,

    Then I think the problem comes from the value of the defaultMemberTypeAlias attribute, which is set to "Another Type". The value of that attribute should be the alias name of an actual member type in the Umbraco back-end.

    In the Umbraco back-end, if you go to the "Members" section, one of the root nodes of the tree that appears is "Member Types". You should use the alias of an existing type, or else create e new member type, and use the alias as value of the attribute in the web.config.

    Hope this helps.

    Cheers,

    Michael.

  • Natalia Langa 12 posts 31 karma points
    Jun 04, 2012 @ 12:02
    Natalia Langa
    0

    Unfortunately that didn't help... I'm still getting the same error.

    But thanks anyway.

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 04, 2012 @ 12:36
    Michael Latouche
    0

    Natalia,

    Maybe a stupid question, but did you take over the database connection string in the web.config of your MVC sub-app?

    Cheers,

    Michael.

  • Natalia Langa 12 posts 31 karma points
    Jun 05, 2012 @ 12:49
    Natalia Langa
    0

    Hi,

    Yes, I use the same connection string and it works - I've got access to other database tables.

  • thetallbloke 8 posts 29 karma points
    Jul 17, 2012 @ 02:56
    thetallbloke
    0

    Hi Natalia,

    Did you ever figure this problem out..??

  • thetallbloke 8 posts 29 karma points
    Jul 17, 2012 @ 07:20
    thetallbloke
    0

    I had the same problem until I added in the following appSetting:

    <add key="umbracoDbDSN" value="server=localhost;database=MSSM;trusted_connection=true;" />

    This got me past the "object reference not set to an instance of an object" problem, but then I immediately get w3wp.exe errors and VS2010 trying to debug.

    When I get into VS2010 it says 

    Cannot evaluate expression because the current thread is in a stack overflow state.

    Would love to get this nailed...

    I've tried using a standard, non-umbraco, membership database, and the page/login/everything works fine...

    If anyone has a working example of this, it would be awesome if you could post a link to the code..

  • thetallbloke 8 posts 29 karma points
    Jul 17, 2012 @ 08:20
    thetallbloke
    0

    Hi guys,

    For those that are having issues with this, I got it working today, for a plain asp.net site.

    I followed all the steps above, but also had to create a /config/umbracoSettings.config file..  mine was originally copied from another umbraco site, but then I started playing around with it and it's now blank...  It seems that the file just needs to exist to stop the overflow issue..

    Hope that helps..

  • Natalia Langa 12 posts 31 karma points
    Jul 17, 2012 @ 10:33
    Natalia Langa
    0

    Hi,

    Can you send me the project you were able to run? I still have some issues... Maybe I'm doing something else wrong. Your code could help

  • thetallbloke 8 posts 29 karma points
    Jul 18, 2012 @ 00:10
    thetallbloke
    0

    sure...  whats your email address...??  I couldn't get it from your profile...

    Are you getting a new error..???

     

  • Natalia Langa 12 posts 31 karma points
    Jul 18, 2012 @ 11:04
    Natalia Langa
    0

    natalia.langa at gmail.com

    It's an error with "umbraco.providers.members.UmbracoMembershipProvider" type of my UmbracoMembershipProvider.

  • Mohsin 12 posts 71 karma points
    Jul 09, 2013 @ 12:31
    Mohsin
    0

    i also got same error on Registeration page

    login works super fine plz help

  • Mohsin 12 posts 71 karma points
    Jul 09, 2013 @ 12:51
    Mohsin
    0

    Thanks Michael 

    defaultMemberTypeAlias helped me sooooo much

     

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jul 09, 2013 @ 13:37
    Michael Latouche
    0

    Hi Mohsin,

    Glad to hear that ;-)

    Cheers,

    Michael.

  • Ian Grainger 71 posts 135 karma points
    Mar 13, 2015 @ 13:02
    Ian Grainger
    0

    I know this thread is old - but I had something similar working on v4 - but I'm not able to upgrade it to v6 :(

    I'm not actually sure why I need to change anything - but the login fails if I leave the old versions of the libraries.

    If I try to install just the UmbracoCms.Core package then my site randomly crashes after a short time with an error in Umbraco.Core.dll:

    System.NullReferenceException was unhandled - Message: An unhandled exception of type 'System.NullReferenceException' occurred in Umbraco.Core.dll - Additional information: Object reference not set to an instance of an object.

    Call stack:
Please Sign in or register to post replies

Write your reply to:

Draft