1

i cannot login to my MVC3 Web Site located on the server with Forms Authentication from Internet Explorer.

My ASP.NET MVC3 web site using forms authentication. I got problems on authentication when using the site via Internet Explorer.

If i m using the site from local (Development environment or From hosting server machine with remote desktop connection) login works with no problems. But when i try to login to the web site located on the server from my local machine, i cannot get past the login page.

Tried changing ie security and privacy options to allow cookies, added my domain to trustes domains. But still i cannot get past the login page.

Here is my login code after all the authentication checks (User name, password etc.)

...
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("/");
}

...

and 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>

Any thoughts would be appriciated, because i run out of ideas.

Thanks for reading.

0

1 Answer 1

2

This has been a know bug of ie10 (IE10 User-Agent causes ASP.Net to not send back Set-Cookie (IE10 not setting cookies)).

I have installed this(http://support.microsoft.com/kb/2600088) hotfix to server and the issue is resolved. But beware this fix may / will reset your iis extension settings and Wildcard aplication maps.

So if you are using MVC follow the instructions listed on the answer to this(MVC3 publishing and IIS 6) question after installing the hotfix. To be able to fix the "Directory Listing Denied" error.

1
  • Seems web.config fix is right fix for me... your SO link here helped locating it.. thanks :-)
    – Kris
    Jan 27, 2016 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.