December 14, 2009

Workaround: Integrating Windows Identity Foundation and Sitefinity


After adding an STS reference to your Sitefinity web site, you are able to get to the STS login, but after logging in, the website goes into an infinite refresh loop.


Sitefinity takes over the ASP.NET pipeline at an inopportune moment for Windows Identify Foundation.


Add a new ASP.NET page to your project called STS.aspx. The page can be blank. It's just there so that the ASP.NET pipeline will remain active at the proper time.

In your web.config, update your audienceUris and realm in the windows.identity section to point to [domain]/STS.aspx instead of just [domain].

Comment out the WSFederationAuthenticationModule httpModule and add this one in its place:
<add name="SitefinityWSFederationAuthenticationModule" type="SitefinityWSFederationAuthenticationModule, App_Code" />

Add a new class to your App_Code folder called SitefinityWSFederationAuthenticationModule.cs with this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.IdentityModel.Web;
using Telerik;

public class SitefinityWSFederationAuthenticationModule : WSFederationAuthenticationModule

protected override void OnRedirectingToIdentityProvider(RedirectingToIdentityProviderEventArgs e)
UriBuilder ub = new UriBuilder(HttpContext.Current.Request.Url);
ub.Path = "/STS.aspx";
ub.Query = String.Empty;
e.SignInRequestMessage.Realm = ub.Uri.ToString();



Raimonds Rudmanis said...


I believe I did all the steps you described in this blog entry with SiteFinity version 4.2, but unfortunately I am still getting the infinite loops.

Any idea what could be wrong here?

Thank you in advance,

Michael Russell said...


This post was in reference to Sitefinity 3.7 which was on .NET 3.5.

I will investigate integration with .NET 4 later this week.