问题
after migrating from mvc2 - mvc3 with minor issues ... I encounter the following problem when calling Membership.GetAllUsers
it seems that instead of System.Web.Security.SqlMembershipProvider WebMatrix.WebData.SimpleMembershipProvider is kicking in. I am using WebMatrix to get razor helpers to work with MVC3. Tried a bunch of things but without success.
IIS7 administration config looks like this
<trustedProviders allowUntrustedProviders="false">
<add type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</trustedProviders>
[NotSupportedException: Specified method is not supported.] WebMatrix.WebData.SimpleMembershipProvider.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords) +28 System.Web.Security.Membership.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords) +45
回答1:
In ASP.NET MVC 3 Beta there was a bug where some additional features were enabled by mistake. There are some config settings to disable them, but they shouldn't be needed anymore.
In ASP.NET MVC 3 RC (which was released earlier this week) they should all be fixed. You'll want to make sure that in your web.config files and project references you are not referencing any of the "WebMatrix" DLLs.
回答2:
What about your web.config, specifically the system.web.membership section?
<system.web>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<system.web>
回答3:
found solution. Seems that changing the defaultProvider to another setting is the solution. I guess WebMatrix was registers using "AspNetSqlMembershipProvider" as it's name -> but's a guess unfortunately
<membership defaultProvider="SQL">
<providers>
<clear />
<add name="SQL" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="images" passwordFormat="Clear" />
</providers>
</membership>
来源:https://stackoverflow.com/questions/4147287/asp-net-mvc-webmatrix-membershipprovider-kicking-in