我遇到会员身份验证问题。我有两个网站,website1和website2,它们都使用SQL成员资格提供程序(SQLEXPRESS)进行表单身份验证。我有两种情况:
不要发布website1并尝试使用user1登录website1 - >正常工作 不发布网站2并尝试登录 - >它显示以前登录的用户(Website1用户) - >完美
发布网站1并登录 - >工作正常 发布website2并尝试登录 - >它没有显示site1的登录用户(不知道为什么)
然后登录website2并打开website1 - >它不会显示web2登录用户或任何用户......
看起来饼干有问题......
我的web.config看起来像这样:
<authentication mode="Forms">
<forms loginUrl="~/LogOn/LogOn" timeout="2880" protection="All"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
</providers>
</membership>
如果您对此有任何想法,请告诉我......
感谢, swetha
答案 0 :(得分:1)
您需要为每个网站建立相同的machineKey。生成一个here
并将此元素放在web.config中,看看它是怎么回事。
另外,应用程序名称必须相同。见this
您可能需要启用enableCrossAppRedirects
...
<system.web>
...
<machineKey
validationKey="36DFB653C93BE95D70071E2033069338CC8AB908B75639BDEACE846838D9455B7926BA0C50CFDD4F8361643C200913244C3DBC14482895FC05B5CE6B8F24F2A2"
decryptionKey="AC737C3E32A594AB50EF38C3BB40537A4794F2E638D859898368BD1B35A5FF81"
validation="SHA1" decryption="AES"
/>
...
</system.web>
...