Event receivers seems to have this problem. Best option is to go with custom Workflow and make it fire on Item Added.
Internally if you are updating the corresponding list, then you may have to DISABLE event firing first & the use listItem.SystemUpdate()
You can use below code snippet:
private void OnAddedActivated_Invoked(object sender, ExternalDataEventArgs e)
{
SPListItem wfItem = this.workflowProperties.Item;
//Here you can call the CreateSubSite();
wfItem["SiteCreated"] = "YES"; //Set a flag if requires
UpdateWorkFlowItem(true);
}
Helper Method:
private void UpdateWorkFlowItem(bool bisDisableEventFiring)
{
try
{
if (bisDisableEventFiring)
{
SPUtility.ValidateFormDigest();
workflowProperties.Web.AllowUnsafeUpdates = true;
WorkFlowEventFiring objEventFiring = new WorkFlowEventFiring();
objEventFiring.Disable();
workflowProperties.Item.SystemUpdate();
objEventFiring.Enable();
workflowProperties.Web.AllowUnsafeUpdates = false;
}
else
{
workflowProperties.Item.SystemUpdate();
}
}
catch (Exception ex)
{
}
}
Helper Class
public class WorkFlowEventFiring : SPItemEventReceiver
{
public WorkFlowEventFiring()
{
}
public void Disable()
{
this.EventFiringEnabled = false;
}
public void Enable()
{
this.EventFiringEnabled = true;
}
}