Copied to clipboard

Flag this post as spam?

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


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

    Use Umbraco membership (and profile) provider in non-Umbraco ASP.NET web forms site

    Hi, I have a mobile version of an Umbraco website which is just an ASP.NET web project, but I added the code necessary to allow users to login using the Umbraco v4 membership provider.

    I've upgraded my main site (and therefore database) to v6 (planning to go to v7 ASAP) but using the v4 membership provider doesn't work any more. I tried to install the UmbracoCms.Core package - and I can run the site, but I get an error after it's been running about a minute - something to do with Umbrac.Core.Sync.ServerEnvironmentHelper.GetBaseUrl -> Core.StringExtensions.EnsureEndsWith :( (it's a generic 'Object reference not set to an instance of an object' error).

    It feels like I'm just missing some config, but trying to copy all the config I could see didn't help unfortunately.

    Surely other people have got this working? If so - please help! :)

    Thanks!

    (I also bumped this post: https://our.umbraco.org/forum/developers/api-questions/32259-How-to-use-umbraco-membership-provider-in-non-umbraco-NET-MVC-application which was similar - but I assume was also v4, which I had working).

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

    Follow up: to try to make things as simple as possible I've created a new web forms application, added the UmbracoCms.Core package and set up the connectionstring and providers:

    <appSettings>    
    <addkey="umbracoDbDSN"value="server=.;database=dbname;integrated security=true"/>
       
    <addkey="umbracoConfigurationStatus"value="6.2.5"/>
     
    </appSettings>
     
    <connectionStrings>
       
    <addname="umbracoDbDSN"connectionString="server=.;database=dbname;integrated security=true"providerName="System.Data.SqlClient"/>
     
    </connectionStrings>
       
    <!-- Membership Provider -->
       
    <machineKeydecryptionKey="x"validationKey="x"validation="SHA1"decryption="AES"/>
       
    <membershipdefaultProvider="UmbracoMembershipProvider"userIsOnlineTimeWindow="15">
         
    <providers>
           
    <clear/>
           
    <addname="UmbracoMembershipProvider"type="umbraco.providers.members.UmbracoMembershipProvider"defaultMemberTypeAlias="Candidate"umbracoApprovePropertyTypeAlias="isApproved"enablePasswordReset="true"minRequiredNonalphanumericCharacters="0"minRequiredPasswordLength="5"maxInvalidPasswordAttempts="15"passwordAttemptWindow="10"passwordStrengthRegularExpression="[\w_\-]{5,100}"enablePasswordRetrieval="false"passwordFormat="Hashed"requiresQuestionAndAnswer="false"requiresUniqueEmail="true"connectionStringName="umbracoDbDSN"/>
           
    <addname="UsersMembershipProvider"type="umbraco.providers.UsersMembershipProvider"enablePasswordRetrieval="false"enablePasswordReset="false"requiresQuestionAndAnswer="false"passwordFormat="Hashed"connectionStringName="umbracoDbDSN"/>
         
    </providers>
       
    </membership>
       
    <profiledefaultProvider="UmbracoMemberProfileProvider"enabled="true">
         
    <providers>
           
    <clear/>
           
    <addname="UmbracoMemberProfileProvider"type="umbraco.providers.members.UmbracoProfileProvider, umbraco.providers"/>
         
    </providers>
         
    <properties>
           
    <clear/>
           
    <addname="salutation"allowAnonymous="false"provider="UmbracoMemberProfileProvider"type="System.String"/>
           
    <addname="custom1"allowAnonymous="false"provider="UmbracoMemberProfileProvider"type="System.Int32"/>
           
    <addname="custom2"allowAnonymous="false"provider="UmbracoMemberProfileProvider"type="System.String"/>
           
    <addname="isDeleted"allowAnonymous="false"provider="UmbracoMemberProfileProvider"type="System.Boolean"/>
         
    </properties>
       
    </profile>
       
    <!-- added by NH to support membership providers in access layer -->
       
    <roleManagerenabled="true"defaultProvider="UmbracoRoleProvider">
         
    <providers>
           
    <clear/>
           
    <addname="UmbracoRoleProvider"type="umbraco.providers.members.UmbracoRoleProvider"/>
         
    </providers>
       
    </roleManager>

    And when trying to call System.Web.Security.Membership.ValidateUser() with known-good user/pass I get an 'Object reference not set to an instance of an object' in umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName.

    Added the umbracoSettings.config, too.

Please Sign in or register to post replies

Write your reply to:

Draft