See update at bottom of question
I have an ASP.NET 2.0 web application (say https://mysite.somedomain.com/ ) that uses forms authentication. I want to integrate an ASP.NET 4.0 web application on this site based on https://mysite.somedomain.com/NewApp/ . Forms Auth is working on an external application, but the internal application rejects the cookie.
web.config on an external (ASP.NET 2.0) web application contains:
<httpCookies requireSSL="true"/> <authentication mode="Forms"> <forms name="MySiteWebAuth" loginUrl="/Login.aspx" protection="All" path="/" timeout="90" requireSSL="true" slidingExpiration="true"/> </authentication> <machineKey (same machine key is in both configs) validation="SHA1" decryption="AES"/> <authorization> <deny users="?"/> <allow users="*" /> </authorization>
web.config on an internal (ASP.NET 4.0) web application contains:
<authentication mode="Forms"> <forms name="MySiteWebAuth" loginUrl="/Login.aspx" protection="All" path="/" timeout="90" requireSSL="true" slidingExpiration="true" ticketCompatibilityMode="Framework20"/> </authentication> <machineKey (same machine key is in both configs) validation="SHA1" decryption="AES"/>
This is the code in Login.aspx.cs that sets the cookie on successful authentication:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, ApplicationContext.User.Identity.Name, DateTime.Now, DateTime.Now.AddMinutes(90), false, ApplicationContext.User.Identity.SessionID.ToString() ); HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket) ); cookie.Path = FormsAuthentication.FormsCookiePath; cookie.HttpOnly = true; Response.Cookies.Add(cookie);
If I log into an external web application, go to the page inside the internal web application, it redirects to the login page and writes Forms authentication failed for the request. Reason: The ticket supplied was invalid. Forms authentication failed for the request. Reason: The ticket supplied was invalid. in the event log on the server.
How to get an ASP.NET 2.0 Forms Auth ticket that will be accepted by the ASP.NET 4.0 internal web application?
Refresh . It works under HTTPS IIS 7.5, but not under HTTPS IIS 7.0. Do some more research.
Update 2 . We applied Server 2008 SP2 to the server along with a recent patch for the DoS-DoS collision of DoS, and since then the sharing of cookies has worked.