ASP.NET成员 - 登录本地工作,在Azure上失败 [英] ASP.NET Membership - login works locally, fails on Azure

查看:215
本文介绍了ASP.NET成员 - 登录本地工作,在Azure上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个MVC3的网站,我有与ASP.NET成员一个令人费解的问题。我使用连接到SQL Azure数据库System.Web.Providers 1.0.1。

I'm working on an MVC3 site, and I've got a puzzling problem with ASP.NET Membership. I'm using System.Web.Providers 1.0.1 connected to a SQL Azure database.

因为它是现在,同样的用户名/密码登录我下的计算仿真运行时,在适当的Azure下运行时失败。我可以看到它使用正确的数据库,作为失败的密码尝试在会员数据库正在更新计数器。

As it is now, the same username/password that logs me in when running under the Compute Emulator fails when running under Azure proper. I can see that it's using the right database, as the Failed Password Attempts counter in the membership database is being updated.

推荐答案

我跟踪下来,这要归功于一些信息在<一个href=\"http://geekswithblogs.net/DavidHoerster/archive/2010/06/15/asp.net-membership-password-hash----.net-3.5-to-.net-4.aspx\"标题=ASP.NET会员密码哈希 - .NET 3.5到.NET 4升级惊喜!>本文由大卫Hoerster 。问题是,在Azure上的默认密码散列算法是从.NET 4.0的默认值不同。它被设置为SHA1在Azure上,并HMACSHA256是4.0新标准设置。

I tracked it down, thanks to some info in this article by David Hoerster. The problem is that the default password hashing algorithm on Azure is different from the .NET 4.0 defaults. It is set to SHA1 on Azure, and HMACSHA256 is the new standard setting on 4.0.

这可以通过在web.config中明确指定散列值类型是固定的。如果您决定使用像HMACSHA256的方法,请确保您还指定计算机密钥 - 否则你会遇到类似的问题,因为自动生成的计算机密钥将从服务器不同服务器

This can be fixed by specifying the hash type explicitly in web.config. If you decide to use a method like HMACSHA256, make sure you also specify a machine key - otherwise you will run into similar problems as the autogenerated machine key will differ from server to server.

您需要更改的配置元素的&LT;的machineKey> 的下的&LT;的System.Web> 的:

The configuration element you need to change is <machinekey> under <system.web>:

<machineKey decryptionKey="PUT_DECRYPTION_KEY_HERE"
            validationKey="PUT_VALIDATION_KEY_HERE"
            decryption="AES"
            validation="HMACSHA256" />

您可以使用<一个href=\"http://www.sourcetree.net/sourcetree/Development/Aspnet%20Examples/GenerateMachineKeyForWebConfig.aspx\"标题=生成计算机密钥的web.config文件>本机密钥生成中以适当的格式生成随机密钥。

You can use this machine key generator to generate random keys in the proper format.

这篇关于ASP.NET成员 - 登录本地工作,在Azure上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆