public static string OutputFormsAuthenticationCookie(HttpRequest request) { string sRet = ""; string sCookieName = FormsAuthentication.FormsCookieName; DebugOutputHelper.TracedLine(" sCookieName=" + sCookieName); HttpCookie c = request.Cookies[sCookieName]; if (c != null) // && c.HasKeys the cookie exists! { string cookie = ""; try { cookie = HttpContext.Current.Server.UrlDecode(c.Value); FormsAuthenticationTicket fat = FormsAuthentication.Decrypt(cookie); //TODO extend fat sRet = String.Format("FormsAuthenticationTicket for CookieName={0} is:{1}\n", sCookieName, FormsAuthenticationTicketAsString(fat, "")); } catch { sRet = String.Format("Unable to retrieve FormsAuthenticationTicket from cookie. FormsCookieName={0} cookie={1}\n", sCookieName, cookie); } } else { sRet = String.Format("No FormsAuthentication Cookie found. FormsCookieName={0}\n", sCookieName); sRet += TraceOutputHelper.CookieCollectionAsString(request.Cookies, "all cookies");; } return(sRet); }
public static void PrintCookies(CookieCollection cookies, string sComment, LoggingOutputLevel level) { Debug.WriteLine(TraceOutputHelper.CookieCollectionAsString(cookies, sComment, level)); }