I have created two custome membership providers that I would like to add to my web.config. The first one would开发者_StackOverflow中文版 be the default that the asp.net application would use. The second would be called by a WCF service that I have in the same application.
The providers in the membership section of my web.config looks like the following:
<add name="SiteProvider" type="MyNameSpace.SiteProvider, MyNameSpace" ApplicationName="Si2" EnablePasswordReset="true" PasswordStrengthRegularExpression="(?=[\w$#_ ]{8,})(?=.*?\d)(?=.*?[A-z])[\w$#_ ]*" ResetPasswordMinimumLength="8" ResetPasswordPattern="USL9SLU9SLU9SLLLL" ResetPasswordAllowDuplicateCharacters="false" />
<add name="WCFProvider" type="MyNameSpace.WCFProvider, MyNameSpace" ApplicationName="Si2" EnablePasswordReset="true" PasswordStrengthRegularExpression="(?=[\w$#_ ]{8,})(?=.*?\d)(?=.*?[A-z])[\w$#_ ]*" ResetPasswordMinimumLength="8" ResetPasswordPattern="USL9SLU9SLU9SLLLL" ResetPasswordAllowDuplicateCharacters="false" />
I receive the error "Item has already beed added. Key in dictionary: 'SiteProvider' Key being added: 'SiteProvider'" any time I browse to the site.
This doesnt make sense to me sense they have unique names. If i remove the second provider the site is browseable.
Any help on adding this second provider would be appreciated.
The simplest solution would be to move the webservice into a different project.
Also, make sure you call <clear/>
before adding providers and include a default one...
<membership defaultProvider="Siteprovider">
<providers>
<clear/>
<add name="SiteProvider" type="MyNameSpace.SiteProvider, MyNameSpace" ApplicationName="Si2" EnablePasswordReset="true" PasswordStrengthRegularExpression="(?=[\w$#_ ]{8,})(?=.*?\d)(?=.*?[A-z])[\w$#_ ]*" ResetPasswordMinimumLength="8" ResetPasswordPattern="USL9SLU9SLU9SLLLL" ResetPasswordAllowDuplicateCharacters="false" />
<add name="WCFProvider" type="MyNameSpace.WCFProvider, MyNameSpace" ApplicationName="Si2" EnablePasswordReset="true" PasswordStrengthRegularExpression="(?=[\w$#_ ]{8,})(?=.*?\d)(?=.*?[A-z])[\w$#_ ]*" ResetPasswordMinimumLength="8" ResetPasswordPattern="USL9SLU9SLU9SLLLL" ResetPasswordAllowDuplicateCharacters="false" />
</providers>
</membership>
You could try the solution in this forum post: http://forums.asp.net/p/1112089/1714276.aspx
Have you tried putting a separate web.config file in the webservice folder? I doubt that it will work, but it might be worth a try.
精彩评论