Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mhwelander
Created August 26, 2016 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhwelander/6a9378fd454357e13ee4082a3b2ef8e9 to your computer and use it in GitHub Desktop.
Save mhwelander/6a9378fd454357e13ee4082a3b2ef8e9 to your computer and use it in GitHub Desktop.
public class Contacts : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
try
{
bool flag = false;
ID id;
// Get contact data from query string
string contactIdentifier = context.Request["cid"];
string contactFirstName = context.Request["firstname"];
if (!string.IsNullOrEmpty(contactIdentifier))
{
try
{
// Create a session for the contact - this session will be very short, but
// ensures that you are writing data to the same shared session state as the
// currently ongoing session
Tracker.Initialize();
Tracker.StartTracking();
Tracker.Current.Session.Identify(contactIdentifier);
var personalFacet = Tracker.Current.Contact.GetFacet<IContactPersonalInfo>("Personal");
personalFacet.FirstName = contactFirstName;
flag = true;
}
finally
{
Tracker.Current.CurrentPage.Cancel();
context.Response.Write(flag);
}
}
}
finally
{
// Abandon session - facet data will be flushed to the xDB at this point, but the updated information will
// be available to any session that is still ongoing
HttpContext.Current.Session.Abandon();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment