© 2019 by Sayantan Basu

  • Sayantan Basu

Simplest Way to Create Custom Claim in DXA with .Net

I have already written a blog on how to create a custom claim in Java based web application using ADF claim cartridge. Also you can refer the bolg from Jan Horsman [ weather-cartridge] for same type of implementation.

Similarly you can create the Java based ADF claim cartridge and use it in .Net application.

But sometimes we don’t want to mix the technology because of several reason (Client

Adding Claims to the Claim Store at the application level is quite simple in .Net using Tridion Content Delivery API.

Suppose you want to check the user name from cookie, if it exists then want to store it in your custom claim –

Here are the steps–

  1. First complete all the preliminary configuration

  2. Add Custom Claim Uri in cd_ambient_conf.xml [for example]

<Claim Uri=”taf:claim:myclaim:username” />
  1. Add Prefix in smarttarget_conf.xml [for example]

<taf_claim_myclaim >cookie</taf_claim_myclaim >

2. Create your own HttpModule by inheriting IHttpModule. Make sure that the name of the custom module is unique..gist table { margin-bottom: 0; }

3. ADF itself loads as module so place your custom httpmodule after the ADF module under the modules section in the web.config file. Here is the example-

<modules runAllManagedModulesForAllRequests=”true”> <add name=”AmbientFrameworkModule” type=”Tridion.ContentDelivery.AmbientData.HttpModule” preCondition=”managedHandler” /> <add name=”DxaStaticContentModule” type=”Sdl.Web.Mvc.Statics.StaticContentModule” /> <add name=”AmbientDataFrameworkCustomHttpModule” type=”Sdl.Web.Site.Helper.HttpModules.AmbientDataFrameworkCustomHttpModule” /> </modules>

Now you can run your application and check the value is properly set or not.

For that you can also check this blog from Jan Horsman. Personally I always prefer to set that page in my application, it helps me to check the Claim Store values at any point of time through the browser.

#Claim #Web8 #DXA #ADF #SDLWeb8