In the first of our “Starring You” slots, Gary Cox shows us how to use the email address as the user name when using XPO. Don’t forget, if you have a great XPO or XAF tip that you think other users could benefit from and you’d like your name “up in lights”, then drop me an email at garysATdevexpressDOTcom with your idea.
Now, without further ado, I’ll let Gary tell us about membership and XPO.
Everyone wants to keep things simple, and when it comes to Membership following the standards will keep things simple. However, since we use XPO, the standards can still be followed but , at the same time, we can apply our own signature to our work. I use XPO and needed to handle Membership and Roles within my application. So to make a long story short I implemented this and wanted to share with you guys. In my case I needed to provide the ability to either use the User Name as the User Name or the Email Address field as the User Name. What this means is, if you use the standard .NET Membership controls and if useEmailAsUserName is true, then the code will expect an email address instead of the User Name. I made this a setting in the web.config.
Membership is configured like so:
<membership defaultProvider="PersistentMembership">
<providers>
<add name="PersistentMembership"
type="Persistent.Membership.PersistentMembershipProvider, Persistent.Membership"
useEmailAsUserName="false" />
</providers>
</membership>
Role Manager is configured like so:
<roleManager defaultProvider="UserRolesProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookiePath="/"
cookieTimeout="30"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="All"
>
<providers>
<clear />
<add name="UserRolesProvider"
type="Persistent.Membership.UserRolesProvider, Persistent.Membership"
applicationName="PersistentRoles"
writeExceptionsToEventLog="false" />
</providers>
</roleManager>
I hope this helps at least one person and if you have any problems please let me know and I will assist you in correcting them. By the way, this was compiled with 8.2.3. You can download the code from here.