Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6382067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:28:29+00:00 2026-05-25T02:28:29+00:00

Here an interesting feature of ASP.NET FormsAuthentication explained in this SO answer: How do

  • 0

Here an interesting feature of ASP.NET FormsAuthentication explained in this SO answer: How do you pass an authenticated session between app domains

Quick summary; you can create two ASP.NET websites with the same encryption keys. WebsiteA can create a formsauth token, and redirect to WebsiteB with the token in the querystring (or POST body). Switch on EnableCrossAppRedirects in WebsiteB and ASP.NET detects the token and creates the formsauth cookie. In code:

FormsAuthentication.RedirectFromLoginPage("alice", true);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket("Alice", true, 30);
string encrypted = FormsAuthentication.Encrypt(ticket);
Response.Redirect("http://siteb.dev/Secure/WebForm1.aspx?" + FormsAuthentication.FormsCookieName + "=" + encrypted);

Sounds like a great feature, but where is it documented? I’d feel a bit uneasy using a undocumented feature.

Where I’ve looked – no mention of this feature in any of the MSDN reference. I thought maybe RedirectFromLoginPage would build a redirect like my code above, it doesn’t.

  • EnableCrossAppRedirects – “is checked within the RedirectFromLoginPage method when the redirect URL does not point to a page in the current application. If EnableCrossAppRedirects is true, then the redirect is performed”
  • Forms Authentication Across Applications – some advice on setting the machine keys so that a cookie created on a sub-domain, nothing about EnableCrossAppRedirects
  • forms Element for authentication
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:28:30+00:00Added an answer on May 25, 2026 at 2:28 am

    Having looked at reflector there is a (somewhat undocumented) feature of forms Authentication. When EnableCrossAppRedirects is enabled .NET will, in addition to looking for the auth cookie, attempt to extract the forms authentication “cookie” from either the form post or the query string. This code is embedded in the FormsAuthentication class in the ExtractTicketFromCookie method, where it can clearly been seen trying to find the authentication cookie in the request data.

    if (FormsAuthentication.EnableCrossAppRedirects)
    {
        text = context.Request.QueryString[name];
        if (text != null && text.Length > 1)
        {
            if (!cookielessTicket && FormsAuthentication.CookieMode == HttpCookieMode.AutoDetect)
            {
                cookielessTicket = CookielessHelperClass.UseCookieless(context, true, FormsAuthentication.CookieMode);
            }
            try
            {
                formsAuthenticationTicket = FormsAuthentication.Decrypt(text);
            }
            catch
            {
                flag2 = true;
            }
            if (formsAuthenticationTicket == null)
            {
                flag2 = true;
            }
        }
        if (formsAuthenticationTicket == null || formsAuthenticationTicket.Expired)
        {
            text = context.Request.Form[name];
            if (text != null && text.Length > 1)
            {
                if (!cookielessTicket && FormsAuthentication.CookieMode == HttpCookieMode.AutoDetect)
                {
                    cookielessTicket = CookielessHelperClass.UseCookieless(context, true, FormsAuthentication.CookieMode);
                }
                try
                {
                    formsAuthenticationTicket = FormsAuthentication.Decrypt(text);
                }
                catch
                {
                    flag2 = true;
                }
                if (formsAuthenticationTicket == null)
                {
                    flag2 = true;
                }
            }
        }
    }
    

    Therefore if you enable EnableCrossAppRedirects on both applications, then the first application is authorised to redirect to the external site, and the second application will automatically read in the authentication cookie from the request. You just need to engineer it so that the return login URL either posts the cookie data or sends it in the querystring. You also need to be sure that either the machine keys are synchronised, or that the cookie is encrypted using the external apps machine key (by the first app). It seems by default .NET will send the encrypted authentication cookie in the querystring for you and asume your machine keys are in sync (see MSDN quote below).

    Here’s some more info on MSDN .

    If the CookiesSupported property is true, and either the ReturnUrl
    variable is within the current application or the
    EnableCrossAppRedirects property is true, then the
    RedirectFromLoginPage method issues an authentication ticket and
    places it in the default cookie using the SetAuthCookie method.

    If CookiesSupported is false and the redirect path is to a URL in the
    current application, the ticket is issued as part of the redirect URL.
    If CookiesSupported is false, EnableCrossAppRedirects is true, and the
    redirect URL does not refer to a page within the current application,
    the RedirectFromLoginPage method issues an authentication ticket and
    places it in the QueryString property
    .

    There is a big warning about the impact on security. EnableCrossAppRedirects is a security setting which prevents ASP.NET login controls from redirecting to an external return URL (another web application). With this setting enabled it can be exploited in some forms of attack – a user is sent to the official login page, but on login is redirected to a different application which they may believe is the same. This is why it’s disabled by default.

    One way to help mitigate this when enabling the feature is as follows:

    To improve security when using cross-application redirects, you should
    override the RedirectFromLoginPage method to allow redirects only to
    approved Web sites.

    You also need to ensure the redirect request is served over SSL to protect the “cookie” in transit, as anyone intercepting would be able to gain control of the account.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Interesting one here. I have an ASP.NET 1.1 project that contains a web service
I have an interesting situation where I need to deploy an ASP.NET MVC app
There is an interesting post over here about this, in relation to cross-application flow
I found this interesting thing when I was trying out the new feature optional
I am developing web-application using Google Maps API and ASP.NET Ajax. Here is my
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE
Here's an interesting question. I have a system that attempts to run some initialization
Here's an interesting puzzle. I downloaded Snippet Compiler to try some stuff out, and
Here is an interesting piece of code that my fellow team members were just
Here's an interesting writeup of using eye tracking software to generate heat maps that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.