RoleProvider dosn't work with custom IIdentity and IPrincipal on server
asp.net-mvc-3, httpmodule, iidentity, iprincipal, roleprovider
Solution
I explain that solution and it works for me. I don't now, may be you should rollback to the `AuthenticateRequest` event.If you want to try this way, you have to remove `RoleManagerModule` completely from your project. Try this and let me know if works or nop:
// in your module:
public void Init(HttpApplication context) {
_application = context;
// rollback this line:
_application.AuthenticateRequest += ApplicationAuthenticateRequest;
}
// and in web.config
<!-- in system.web section: -->
</system.web>
<!-- other stufs -->
<httpModules>
<remove name="RoleManager"/>
</httpModules>
</system.web>
<!-- and in system.webServer section: -->
<system.webServer>
<!-- other stufs -->
<modules runAllManagedModulesForAllRequests="true">
<remove name="RoleManager"/>
</modules>
<system.webServer>
Problem
I'm using a custom `IIdentity` and `IPrincipal` in my `ASP.NET MVC` application via `EF 4.3` as expalined here (and follow accepted answer's solution). Also, I have a custom `RoleProvider`. In local (using `IIS Express`), it works currectly. But now, when I upload the application on a real host, it seems all users are in `"admin"` role! e.g. I create a user that is not in role `"admin"`, but it can access to all protected pages (that need `"admin"` role). e.g. `Role.IsUserInRole` always returns `true`. Have you any idea please? Can you help me? Is there any setting that I should to do in `IIS`?