Created
August 26, 2016 13:07
-
-
Save mhwelander/6a9378fd454357e13ee4082a3b2ef8e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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