asp.net MVC webmatrix membershipprovider kicking in

坚强是说给别人听的谎言 提交于 2019-12-01 19:09:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!