FormsAuthentication.Decrypt всегда возвращает ноль - PullRequest
0 голосов
/ 19 января 2012

Я пытаюсь создать объект FormsAuthenticationTicket, расшифровав строку cookie аутентификации, используя следующий подход:

Cookie securityContextCookie = cookies["myCookie"]; 

FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(securityContextCookie.Value); // ticket returns null even with a valid encrypted cookie string

Config:

<roleManager enabled="true" defaultProvider="WebRoleProvider">
      <providers>
        <clear />
        <add name="WebRoleProvider" type="Framework.Security.Providers.WebRoleProvider" connectionStringName="aspnetdb" applicationName="TestApp" />
      </providers>
    </roleManager>
    <membership defaultProvider="WebMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
        <add name="WebMembershipProvider" type="Framework.Security.Providers.WebMembershipProvider" connectionStringName="aspnetdb" applicationName="TestApp" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Clear" />
      </providers>
    </membership>

<machineKey decryption="3DES" decryptionKey="..." validation="3DES" validationKey="..." />
<authentication mode="Forms">
  <forms defaultUrl="dashboard" loginUrl="login" timeout="20" />
</authentication>

Форма входа:

<asp:Login ID="Login1" runat="server" MembershipProvider="WebMembershipProvider"
                Font-Size="13px" TextLayout="TextOnTop" LoginButtonType="Image" LoginButtonText=""
                LoginButtonImageUrl="~/Content/Images/login-button.png" LabelStyle-HorizontalAlign="Left"
                LoginButtonStyle-CssClass="" ToolTip="Log In" RememberMeText="Remember me?"
                FailureAction="Refresh" TitleText="">
                <TextBoxStyle Font-Size="13px" BorderStyle="Solid" BorderWidth="1px" Width="385px"
                    Height="20px" BorderColor="#e1e4ea" CssClass="login-form-textboxes" />
                <LoginButtonStyle Font-Names="Verdana" />
                <InstructionTextStyle Font-Italic="False" ForeColor="#464749" Font-Size="12px" />
                <LabelStyle Font-Size="11px" ForeColor="#939598" Font-Bold="true" CssClass="login-form-labels" />
                <TitleTextStyle Font-Bold="True" Font-Size="14px" ForeColor="#464749" />
                <CheckBoxStyle CssClass="login-form-checkboxes" />
</asp:Login>

Несмотря на то, что значение securityContextCookie выглядит как допустимая зашифрованная строка cookie, я получаю нулевое значение для билета ...

Есть идеи, что может вызвать проблему?

Спасибо за помощь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...