1

Internet Explorer からフォーム認証を使用して、サーバー上にある MVC3 Web サイトにログインできません。

フォーム認証を使用する ASP.NET MVC3 Web サイト。Internet Explorer 経由でサイトを使用すると、認証に問題が発生しました。

ローカル (開発環境またはリモート デスクトップ接続を備えたホスティング サーバー マシンから) からサイトを使用している場合、ログインは問題なく機能します。しかし、ローカル マシンからサーバー上にある Web サイトにログインしようとすると、ログイン ページを通過できません。

つまり、セキュリティとプライバシーのオプションを変更して Cookie を許可し、ドメインをトラスト ドメインに追加しました。しかし、それでもログインページを通過できません。

すべての認証チェック(ユーザー名、パスワードなど)後のログインコードは次のとおりです。

...
string userDataString = userid.ToString();

HttpCookie authCookie = FormsAuthentication.GetAuthCookie(username, rememberme);
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userDataString);

authCookie.Value = FormsAuthentication.Encrypt(newTicket);
Response.Cookies.Add(authCookie);

if (Url.IsLocalUrl(returnurl) &&
    returnurl.Length > 1 &&
    returnurl.StartsWith("/") &&
    !returnurl.StartsWith("//") &&
    !returnurl.StartsWith("/\\") &&
    returnurl.IndexOf("XMLHttpRequest") < 0)
{
    return Redirect(returnurl);
}
else
{
    return Redirect("/");
}

...

および web.config

<?xml version="1.0" encoding="utf-8"?>
...
<configuration>
  <connectionStrings>
    <add name="*******" connectionString="******" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="1.0.0.0" />
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
    <customErrors mode="Off" defaultRedirect="/Error/General">
      <error statusCode="403" redirect="/Error/NoAccess" />
      <error statusCode="404" redirect="/Error/NotFound" />
    </customErrors>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Authentication" timeout="2880" />
    </authentication>

    <machineKey validationKey="*********" decryptionKey="**************" validation="SHA1" decryption="AES" />

    <membership defaultProvider="TestMembershipProvider">
      <providers>
        <clear />
        <add name="TestMembershipProvider" type="Test.Helpers.TestMembershipProvider" connectionStringName="TestContext" />
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="TestRoleProvider" cacheRolesInCookie="true" cookieName="AppRoles" cookieTimeout="20" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
      <providers>
        <clear />
        <add name="TestRoleProvider" type="Test.Helpers.TestRoleProvider" connectionStringName="TestContext" applicationName="/" />
      </providers>
    </roleManager>

    ...

  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

私はアイデアを使い果たしているので、どんな考えでも感謝します。

読んでくれてありがとう。

4

1 に答える 1

2

これは ie10 の既知のバグです ( IE10 User-Agent により、ASP.Net は Set-Cookie を送り返しません (IE10 は Cookie を設定しません) )。

この ( http://support.microsoft.com/kb/2600088 ) ホットフィックスをサーバーにインストールしたところ、問題は解決しました。ただし、この修正により、iis 拡張設定とワイルドカード アプリケーション マップがリセットされる可能性があることに注意してください。

そのため、MVC を使用している場合は、修正プログラムをインストールした後、この質問( MVC3 パブリッシングと IIS 6 ) への回答に記載されている手順に従ってください。「Directory Listing Denied」エラーを修正できるようにします。

于 2013-07-25T12:23:32.970 に答える