开发者

Using System.Web.Providers with Sql Compact

开发者 https://www.devze.com 2023-03-18 02:09 出处:网络
Following the article shanselman i\'m trying to use \"System.Web.Providers\" so you can use memberships, rules and profiles with Sql Server Compact.

Following the article shanselman i'm trying to use "System.Web.Providers" so you can use memberships, rules and profiles with Sql Server Compact.

I installed via Nuget, created a Users.sdf database and copied to the App_Data folder. My Web.config was as follows:

<profile defaultProvider="DefaultProfileProvider">
  <providers>
    <clear />
    <add
      name="DefaultProfileProvider"
      type="System.Web.Providers.DefaultProfileProvider"
      connectionStringName="DefaultConnection"
      applicationName="/" />
  </providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
  <providers>
    <clear />
    <add connectionStringName="DefaultConnection" enablePasswordRetrieval="false"
      enablePasswordReset="true" requiresQuestionAndAnswer="false"
      requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
      minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
      applicationName="/" name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" />
  </providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
  <providers>
    <clear />
    <add connectionStringName="DefaultConnection" applicationName="/"
      name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider" />
  </providers>
</roleManager>
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
  <providers>
    <add
      name="DefaultSessionProvider"
      type="System.Web.Providers.DefaultSessionStateProvider"
      connectionStringName="DefaultConnection"
      applicationName="/" />
  </providers>
</sessionState>

<connectionStrings>
  <add name="Sql_CE" connectionString="Data Source=|DataDirec开发者_如何学Gotory|\Users.sdf;"
       providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

I can not use "aspnet_regsql" because it generates the tables to a SQL Server based

The following error occurs when trying to access the "Web Site Administration Tool" on page security

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: This method cannot be called during the application's pre-start initialization stage.


First rename your connection string to DefaultConnection and remove the \ in front of Users.sdf like so:

<connectionStrings>
  <add name="DefaultConnection" connectionString="Data Source=|DataDirectory|Users.sdf;"
       providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

You say that you

created a Users.sdf database

how? The Providers framework and SqlCe should do this for you. Try deleting the Users.sdf from the App_Data folder and try accessing the "Web Site Administration Tool" again. The provider engine should recreate it for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号