SqlProfileProvider

发布于 2024-10-25 05:40:37 字数 1213 浏览 4 评论 0原文

我试图让 SqlProfileProvider 使用我自己的数据库,我已经使用 aspnet_regsql 设置了数据库,然后使用以下 web.config,但应用程序不断创建 aspnetdb 并且从不填充我的数据库中的任何表。

<connectionStrings>
  <add name="Database"
       connectionString="Server=MYSERVER;Integrated Security=True;Initial Catalog=MYDB"
       providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
  <add name="AspNetActiveDirectoryMembershipProvider"
       type="System.Web.Security.ActiveDirectoryMembershipProvider, 
             System.Web, Version=2.0.3600, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<profile defaultProvider="AspNetSqlProfileProvider">
  <providers>
    <clear/>
    <add name="AspNetSqlProfileProvider"   
         type="System.Web.Profile.SqlProfileProvider"
         connectionStringName="Database"
         applicationName="/"/>
  </providers>
</profile>
<roleManager enabled="false" />

I am trying to get SqlProfileProvider working with my own db, I have set up the db using aspnet_regsql and then the following web.config, yet the application keeps creating an aspnetdb and never populates any of the tables in my db.

<connectionStrings>
  <add name="Database"
       connectionString="Server=MYSERVER;Integrated Security=True;Initial Catalog=MYDB"
       providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
  <add name="AspNetActiveDirectoryMembershipProvider"
       type="System.Web.Security.ActiveDirectoryMembershipProvider, 
             System.Web, Version=2.0.3600, Culture=neutral, 
             PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<profile defaultProvider="AspNetSqlProfileProvider">
  <providers>
    <clear/>
    <add name="AspNetSqlProfileProvider"   
         type="System.Web.Profile.SqlProfileProvider"
         connectionStringName="Database"
         applicationName="/"/>
  </providers>
</profile>
<roleManager enabled="false" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的笑 2024-11-01 05:40:38

尝试在 标记后立即添加 标记。我似乎记得几年前也遇到过类似的问题,这是由我的 web.config 从其他地方继承连接字符串引起的。

http://msdn.microsoft.com/en-us/library/ayb15wz8.aspx

<connectionStrings>
  <clear />
  <add name="Database"
       connectionString="Server=MYSERVER;Integrated Security=True;Initial Catalog=MYDB"
       providerName="System.Data.SqlClient" />
</connectionStrings>

编辑:

实际上,您还应该向您的会员提供商添加 标记。

常见问题:添加提供程序时不要忘记

Try adding a <clear /> tag immediately after the <connectionStrings> tag. I seem to remember having a similar problem years ago that was caused by my web.config inheriting a connection string from somewhere else.

http://msdn.microsoft.com/en-us/library/ayb15wz8.aspx

<connectionStrings>
  <clear />
  <add name="Database"
       connectionString="Server=MYSERVER;Integrated Security=True;Initial Catalog=MYDB"
       providerName="System.Data.SqlClient" />
</connectionStrings>

EDIT:

Actually, you should also add the <clear /> tag to your membership providers as well.

Common Gotcha: Don't forget to <clear/> when adding providers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文