Using XmlMembership and Role provider in other site

Topics: ASP.NET 2.0
Jan 16, 2008 at 12:20 AM
Hi, I want user/passw requirement in some website but I don't want to be complicated with SQL installation(and also paying for that to hosting) instead I want to use the XMLMembershipProvider and XMLRoleProvider that use BlogEngine..
Trying to do that I included BlogEngine.Core.dll, .pdb and .XML files in my bin directory, the user.xml and roles.xml in App_Data, also I included the following lines below my web.config

<machineKey
validationKey="D9F7287EFDE8DF4CAFF79011D5308643D8F62AE10CDF30DAB640B7399BF6C57B0269D60A23FBCCC736FC2487ED695512BA95044DE4C58DC02C2BA0C4A266454C"
decryptionKey="BDAAF7E00B69BA47B37EEAC328929A06A6647D4C89FED3A7D5C52B12B23680F4"
validation="SHA1" decryption="AES"
/>

<authentication mode="Forms">
<forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/Page/login.aspx" cookieless="UseCookies" />
</authentication>

<membership defaultProvider="XmlMembershipProvider" >
<providers>
<clear />
<add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core" description="XML membership provider" xmlFileName="~/App_Data/users.xml"/>
</providers>
</membership>

<roleManager defaultProvider="XmlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">
<providers>
<clear />
<add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core" description="XML role provider" xmlFileName="~/App_Data/roles.xml"/>
</providers>
</roleManager>

but when I run the website I get the following error:


Parser Error Message: Object reference not set to an instance of an object.

Source Error:

Line 48: <providers>
Line 49: <clear />
Line 50: <add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider" description="XML role provider" xmlFileName="~/App_Data/roles.xml"/>
Line 51: </providers>
Line 52: </roleManager>

Source File: C:\xxxxxxxxxx\web.config Line: 50

What I'm doing wrong ???

Thanks in advance.
Jan 16, 2008 at 3:40 PM
Have a look at these articles http://www.dscoduc.com/?tag=/xml for some assistance... I would also encourage you to have a look at these articles for securing your authentication using SSL http://www.dscoduc.com/?tag=/ssl
Jan 16, 2008 at 9:45 PM
Thanks a lot. Perfect !!! Tha's exactly what I was looking for.. and very clear article.