我正在关注这个例子http://msdn.microsoft.com/en-us/library/ms998331.aspx,但似乎搞乱了一些事情。
我一直在
参数不正确。 (HRESULT异常:0x80070057(E_INVALIDARG))
抛出错误:
第30行:if(Roles.IsUserInRole(“TestRole”))
堆栈追踪:
[ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))] [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +337 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) +36 System.Web.Security.AuthorizationStoreRoleProvider.CallMethod(Object objectToCallOn, String methodName, Object[] args) +183 System.Web.Security.AuthorizationStoreRoleProvider.GetClientContextFromName(String userName) +167 System.Web.Security.AuthorizationStoreRoleProvider.GetClientContext(String userName) +70 System.Web.Security.AuthorizationStoreRoleProvider.GetRolesForUserCore(String username) +59 System.Web.Security.AuthorizationStoreRoleProvider.GetRolesForUser(String username) +72 System.Web.Security.RolePrincipal.IsInRole(String role) +164 System.Web.Security.Roles.IsUserInRole(String username, String roleName) +355 System.Web.Security.Roles.IsUserInRole(String roleName) +19 _Default.ShowRoleMembership() in c:\projects\adamtest\Default.aspx.cs:30 _Default.Page_Load(Object sender, EventArgs e) in c:\projects\adamtest\Default.aspx.cs:24 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
我从示例中复制的Role Manager配置
<roleManager
enabled="true"
cacheRolesInCookie="true"
defaultProvider="RoleManagerAzManADAMProvider"
cookieName=".ASPXROLES"
cookiePath="/"
cookieTimeout="30"
cookieRequireSSL="true"
cookieSlidingExpiration="true"
createPersistentCookie="false"
cookieProtection="All">
<providers>
<add name="RoleManagerAzManADAMProvider"
type="System.Web.Security.AuthorizationStoreRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral,
publicKeyToken=b03f5f7f11d50a3a"
connectionStringName="AzManADAMServer"
applicationName="AzManDemo"/>
</providers>
</roleManager>