XmlMembershipProvider dependency

Topics: Business Logic Layer
Jan 5, 2011 at 12:44 AM

XmlMembershipProvider and XmlRoleProvider depend on BlogSettings and I think it's sort of a design flaw, because XmlmembershipProvider cannot be used independently. For example this would be a problem while creating unit tests.

Furthermore, there's no guarantee BlogSettings is initialized at the time when XmlMembershipProvider needs to use. If you select Website|ASP.NET Configuration (in Visual Studio) and then go to the Security tab, it will crash on trying to access BlogSettings.

Perhaps it would better to use another web.config setting to set location of both data storage as well provider storage.

What do you guys think?


Jan 5, 2011 at 8:03 AM

This is a good point about those 2 providers being dependent on BlogSettings.

I think I've seen that error too when pulling up the ASP.NET Configuration in VS ... I didn't look into the cause of the error, but I can believe that it is because of the dependence (or unavailability) of BlogSettings.

I'm not sure what you mean exactly by having a separate web.config file.  But I'm guessing that these 2 providers probably don't rely on BlogSettings too much, so the ideal approach may be to modify these 2 providers so they don't rely on BlogSettings.

As of BE 2.0, XmlRoleProvider also makes a call to the BlogEngine.Core.Right class (another dependency).  This was not ideal, but just something we did at the time.  DbRoleProvider makes the same call to BlogEngine.Core.Right (multiple times in the case of this provider).  It might be possible to rework this part so BE calls into the Role providers, rather than the Role providers calling into BE.

Jan 5, 2011 at 10:12 AM

Yes, I meant to modify those provider to remove dependency.by creating a separate entry in web.config file used to determine by membership/roles provider as well as blog provider. If the entry was not present the default location would be app_data.

Just one idea or perhaps you can think of better option?  

Jan 5, 2011 at 10:16 AM

Actually. it;s looks the suitable entry is there already.


    <add key="StorageLocation" value="~/App_Data/"/>