迁移 asp.net 网站会破坏 Membership Provider
我有一个在连接到 sql server 2000 的 .Net Framework v2 上开发的 asp.net 网站。我正在尝试将其迁移到具有 .Net Framework v3.5 和 sql server 2008 的新服务器。我备份了数据库并将其恢复到新的数据库服务器。我移动了网站并更新了 web.config。但现在我无法登录该网站。我运行 sql profiler 来查看发生了什么,这是当我尝试登录时运行的存储过程。
exec dbo.aspnet_Membership_GetPasswordWithFormat @ApplicationName=N'dev',
@UserName=N'AffiliateBob', @UpdateLastLoginActivityDate=1,
@CurrentTimeUtc='2009-10-26 20:43:23.7130000'
请注意 @CurrentTimeUtc 参数的格式。当我将其放入 sql Management Studio 并运行它时,我收到以下错误消息。
Msg 8114, Level 16, State 1, Procedure aspnet_Membership_GetPasswordWithFormat, Line 0
Error converting data type varchar to datetime.
这是我的 web.config 中的成员资格部分。
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="999"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="999"
passwordStrengthRegularExpression=""
applicationName="dev"/>
</providers>
</membership>
I have a asp.net web site that was developed on the .Net Framework v2 connecting to sql server 2000. I am trying to migrate it to a new server that has the .Net Framework v3.5 on it along with sql server 2008. I backed up the database and restored it to the new database server. I moved the web site and updated the web.config. Now however I cannot login to the website. I ran sql profiler to see what was going on and this is the stored proc that gets run when I attempt to login.
exec dbo.aspnet_Membership_GetPasswordWithFormat @ApplicationName=N'dev',
@UserName=N'AffiliateBob', @UpdateLastLoginActivityDate=1,
@CurrentTimeUtc='2009-10-26 20:43:23.7130000'
Notice the format of the @CurrentTimeUtc parameter. When I put this into sql management studio and run it I get the following error message.
Msg 8114, Level 16, State 1, Procedure aspnet_Membership_GetPasswordWithFormat, Line 0
Error converting data type varchar to datetime.
Here is the membership section from my web.config.
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="999"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="999"
passwordStrengthRegularExpression=""
applicationName="dev"/>
</providers>
</membership>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实证明这是一个
web.config
问题。我通过创建一个新的干净的 web.config 文件并添加旧的 web.config 中的部分来解决这个问题。This turned out to be a
web.config
issue. That I resolved by creating a new cleanweb.config
file and adding sections from the oldweb.config
.如果把日期改成2009-10-10可以吗?如果是这样,则说明您遇到了语言/区域设置问题。 ASP.NET 以 MM/DD 格式发送日期参数,而 SQL Server 需要 DD/MM 格式,反之亦然。检查 ASP.NET 中的此设置以及您的 SQL Server 登录名。
Does it work OK if you change the date to 2009-10-10? If so, you have a language/locale issue. ASP.NET is sending the date parameter in MM/DD and SQL Server is expecting DD/MM or vice-versa. Check this setting in ASP.NET and for your SQL Server login.
在某些情况下,这可能不是最好的解决方案,但这最终解决了我的问题:
http: //forums.asp.net/t/1398826.aspx/1
我最初尝试深入研究会员提供程序存储过程并开始将所有 DateTime 移至 DateTime2,但我确信您可以想象一下打开的蠕虫罐头。无论哪种方式,日期时间转换问题都是一个值得了解的问题。
This may not be the best solution in some cases, but this ended up solving my issue:
http://forums.asp.net/t/1398826.aspx/1
I'd originally tried to dig into the Membership Provider stored procs and start moving all of the DateTime's over to DateTime2's, but I'm sure you can imagine the can of worms that opens up. Either way, the DateTime conversion issue is a good one to know about.