Re: How to Remote a custom membership or profile provider ???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Aha, you are right, I completely overlooked the title and only read the body of your post.

So, it sounds like your question is: how do I configure ASP.NET to use my custom provider? It doesn't really have anything to do with connectionStrings, right?


When you add a custom provider, you need to at least specify a name and a type. Under certain conditions, the configuration below will work:


<roleManager enabled="true" defaultProvider="CustomRoleProvider">
  <providers>
    <add name="CustomRoleProvider" type="MyRoleProvider" />
  </providers>
</roleManager>

The entry above assumes the following: There is a type called MyRoleProvider (no namespace) in the APP_CODE folder of the website.

If your type is NOT in the APP_CODE folder (you define it in a separate Class Library DLL project), you need to specify the assembly within the type attribute (in the form "typename, assemblyname"). In this example, I have a class library "MyRemotableProviders", which contains a custom role provider named "MyRemotableProviders.RemotableRoleProvider".

<roleManager enabled="true" defaultProvider="CustomRoleProvider">
<providers>
<add name="CustomRoleProvider" type="MyRemotableProviders.RemotableRoleProvider, MyRemotableProviders" />
</providers>
</roleManager>


(Note the "name" attribute has nothing to do with the type - it can be anything.)

The example above assumes you added a referece to your DLL from your web project, so the MyRemotableProviders.dll binary is in the website's bin folder. There is no need to specify assembly name in long form (with public key, etc).

Finally, if your DLL is in the GAC instead of the bin folder, you need to specify the long form of the assembly name in the type attribute:

<roleManager enabled="true" defaultProvider="CustomRoleProvider">
<providers>
<add name="CustomRoleProvider" type="MyRemotableProviders.RemotableRoleProvider, MyRemotableProviders, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdefghijklmn" />
</providers>
</roleManager>


To read about the long form (fully qualified) assembly names:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconAssemblyNames.asp


Hope this helps.

Joshua Flanagan
http://flimflan.com/blog
.



Relevant Pages