我無法使用Internet Explorer的表單身份驗證登錄到位於服務器上的我的MVC3網站。表單身份驗證在Internet Explorer上不起作用
我的ASP.NET MVC3網站使用表單身份驗證。通過Internet Explorer使用網站時,我遇到了身份驗證問題。
如果我使用本地(開發環境或從託管服務器與遠程桌面連接)的網站登錄工作沒有問題。但是,當我嘗試從本地計算機登錄到位於服務器上的網站時,我無法通過登錄頁面。
嘗試更改即安全和隱私選項以允許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>
任何想法,將appriciated,因爲我跑出來的想法。
感謝您的閱讀。
似乎web.config修復是正確的修復我...你的SO鏈接在這裏幫助找到它..謝謝:-) – Kris