Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think I've found an answer to this problem and want to circle back and leave an answer for anyone else in the world that might encounter this.</p> <p>My problem was that the <code>HttpContext.Current.Items</code> wasn't matching up between my <code>ActionFilterAttribute</code> and the <code>WSFederationAuthenticationModule</code> so I ended up inspecting the context and adding some checks similar to <a href="http://haacked.com/archive/2011/10/04/prevent-forms-authentication-login-page-redirect-when-you-donrsquot-want.aspx" rel="noreferrer">Phil Haacks Forms Redirect Suppress Example</a></p> <p>Here is what my updated custom <code>WSFederationAuthenticationModule</code> looks like:</p> <pre><code>public class WSFederationServiceAuthenticationModule : WSFederationAuthenticationModule { private static Log4NetLoggingService logger = new Log4NetLoggingService(); protected override void OnAuthorizationFailed(AuthorizationFailedEventArgs e) { base.OnAuthorizationFailed(e); var context = HttpContext.Current; var req = context.Request; var resp = context.Response; if (req == null || resp == null) { logger.Info("WSFedService: Did not find Request or Response"); return; } if ((resp.StatusCode == 302 || resp.StatusCode == 401) &amp;&amp; req.Headers["X-Requested-With"] == "XMLHttpRequest") { logger.Info("WSFedService: Found Redirect and Header"); e.RedirectToIdentityProvider = false; } else { logger.Info(string.Format("WSFedService: Did not find redirect status code or XMLHttpRequest Header: {0}", resp.StatusCode)); } } } </code></pre> <p>And of course, you'll need to add this to your web.config in place of the default authentication module:</p> <pre><code>&lt;system.web&gt; &lt;httpModules&gt; &lt;!-- Old and Busted... &lt;add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt; --&gt; &lt;!-- New Hotness... --&gt; &lt;add name="WSFederationAuthenticationModule" type="MyApp.Web.Authentication.WSFederationServiceAuthenticationModule, MyApp.Web" /&gt; &lt;/httpModules&gt; &lt;/system.web&gt; &lt;system.webServer&gt; &lt;modules&gt; &lt;!-- Old and Busted... &lt;add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler"/&gt; --&gt; &lt;!-- New Hotness... --&gt; &lt;add name="WSFederationAuthenticationModule" type="MyApp.Web.Authentication.WSFederationServiceAuthenticationModule, MyApp.Web" preCondition="managedHandler"/&gt; &lt;/modules&gt; &lt;/system.webServer&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload