Skip to content

Instantly share code, notes, and snippets.

@willprice76
Created October 13, 2016 08:50
Show Gist options
  • Save willprice76/63d2a2e73c33c8b78b4b10ee3f374310 to your computer and use it in GitHub Desktop.
Save willprice76/63d2a2e73c33c8b78b4b10ee3f374310 to your computer and use it in GitHub Desktop.
private void FixUrlClaim()
{
if (AmbientDataContext.CurrentClaimStore == null)
{
throw new Exception("Ambient Data Framework is not configured. Check there is a cd_ambient_conf.xml file, and the AmbientFrameworkModule HttpModule is configured in web.config");
}
var claims = AmbientDataContext.CurrentClaimStore.GetAll();
var uri = new Uri("taf:request:full_url");
//In order for Audience Manager to work, the ADF must contain a full_url claim with an actual Tridion page URL
// as it uses this to determine publication id and thus other configuration
//The request URL is never a valid Tridion page URL (as it does not contain an extension) so we fake it with the root URL
string fakeUrl = String.Format("{0}{1}/{2}", new Uri(claims[uri].ToString()).GetLeftPart(UriPartial.Authority), _publicationResolver.GetBaseUri().AbsolutePath, _configuration.WelcomeFile);
_logger.Debug("Replacing taf:request:full_url Claim in ADF with {0}", fakeUrl);
AmbientDataContext.CurrentClaimStore.Remove(uri);
AmbientDataContext.CurrentClaimStore.Put(uri, fakeUrl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment