ProviderException: InvalidCastException

Posted by JS on Stack Overflow See other posts from Stack Overflow or by JS
Published on 2009-10-13T03:50:58Z Indexed on 2010/03/14 10:05 UTC
Read the original article Hit count: 312

Filed under:
|
|

Few of our clients are regularly getting invalid cast exception, with variations i.e. InvalidCastException / ProviderException, but both generating from method call: System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)

The other variation is:

Exception type: InvalidCastException
Exception message: Unable to cast object of type System.Int32 to type System.String.

I had a look at application event log which shows:

Stack trace:
   at System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)
   at System.Web.Security.RolePrincipal.IsInRole(String role)
   at System.Web.Configuration.AuthorizationRule.IsTheUserInAnyRole(StringCollection roles, IPrincipal principal)
   at System.Web.Configuration.AuthorizationRule.IsUserAllowed(IPrincipal user, String verb)
   at System.Web.Configuration.AuthorizationRuleCollection.IsUserAllowed(IPrincipal user, String verb)
   at System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)*

Has anyone come across this issue, and if so what is the fix?

Thanks

JS

© Stack Overflow or respective owner

Related posts about sqlroleprovider

Related posts about .NET