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 typeSystem.Int32
to typeSystem.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