更改会员数据库名称,找不到用户
我使用 VS 2008 创建了一个 asp.net 站点。我使用 app_data 中的数据库作为成员资格。我将其移至新服务器,并且数据库将附加到 sql server 2008 R2 实例。我想更改数据库名称,以便它更好地适应服务器的其余部分。由于我将名称从 ASPNETDB.mdf 更改为 Reporting.MDF,我无法登录,并且 ASP.NET 说我没有用户。我使用了 VS 中的重命名功能并更新了我的连接字符串。
<connectionStrings>
<add name="MembershipConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Reporting.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!--added to create new membership to connect to-->
<roleManager enabled="true">
<providers>
<clear/>
<add connectionStringName="MembershipConnectionString" applicationName="WebSite2" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken="/>
</providers>
</roleManager>
<membership defaultProvider="SqlMembershipProvider">
<providers>
<clear/>
<add connectionStringName="MembershipConnectionString" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="WebSite2"
requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10" passwordStrengthRegularExpression=""
name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" />
</providers>
</membership>
用户:0 提供者:测试以检查数据库是否正常工作。
编辑:我删除了公钥,以防它以某种方式与我绑定。
编辑:我将名称改回 aspnetdb,但它仍然不起作用。
如果我删除会员代码,它会再次起作用。这是将名称更改回 aspnetdb 后的结果。我又回到了起点。
I created an asp.net site using VS 2008. I was using a db in app_data for membership. I am moving this to a new server and the db will be attached to a sql server 2008 R2 instance. I wanted to change the db name so it would fit in better with the rest of the server. Since I changed the name from ASPNETDB.mdf to Reporting.MDF I cannot login and ASP.NET says I have no users. I used the rename function in VS and updated my connectionstring.
<connectionStrings>
<add name="MembershipConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Reporting.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!--added to create new membership to connect to-->
<roleManager enabled="true">
<providers>
<clear/>
<add connectionStringName="MembershipConnectionString" applicationName="WebSite2" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken="/>
</providers>
</roleManager>
<membership defaultProvider="SqlMembershipProvider">
<providers>
<clear/>
<add connectionStringName="MembershipConnectionString" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="WebSite2"
requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10" passwordStrengthRegularExpression=""
name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" />
</providers>
</membership>
Users: 0
Provider: Test to check db works fine.
edit: I removed the publicKey in case it is tied to me in some way.
edit: I changed the name back to aspnetdb and it still does not work.
If i delete the membership code it works again. This is after changing the name back to aspnetdb. I am back where I started.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您再次遇到此问题,则可能是由于忘记在
web.config
中正确设置applicationName
属性造成的。这是对常见问题的详细解释。如果您将问题中的web.config
文件与答案中的web.config
文件进行比较,您'您将看到两个文件中的applicationName
属性具有不同值;WebSite2
与/
。If you have this problem again it's likely caused by forgetting to properly set the
applicationName
attribute inweb.config
. Here's a great, detailed explanation of the common problem. If you compare theweb.config
file from your question to yourweb.config
in your answer, you'll see that theapplicationName
attributes in the two files have different values;WebSite2
versus/
.我通过打开 machine.config 并复制所有成员详细信息修复了此问题。然后使用
清除
在每个部分。
I fixed this by opening machine.config and copying all of the membership details. Then used
clear
in every section.
首先尝试附加 aspnetdb 数据库。然后使用 Sql Management Studio 对其进行重命名。
Try attaching the aspnetdb database first. Then rename it using Sql Management Studio.