By the time the below code is accessed in Controller/View Rendering, any personlization rules are applied.
Item properties point to the the datasource are the personalized ones configured for the rule that is applied.
Below code shows how to get the RuleList xml and pull the default DataSource out of it.
string text = rendering.Properties["RenderingXml"];
var renderingReference =
new RenderingReference(XmlExtensions.ToXmlNode(XElement.Parse(text)), <contextlanguage>, <contextdatabase>);
var DefaultDataSource = renderingreference.Settings.DataSource;
Once the Rendering reference is obtained, the default datasource can be pulled from its
The order of DataSource for the rendering will be
- DataSource selected in the Action section of Rule that is applied
- The order of Default DataSource will be
- DS selected in the Action section
- If Action Section is empty, then DS selected from Rendering Parameters
- If none of them are set then
RenderingReference.Settings.DataSource is empty. But the actual Rendering DataSource set to PageItem