I have a simple form that takes an email which I use to identify a Contact.
I also have a label with some text that changes based on a condition on the same page.
After identifying the Contact I return the same view. However, for the condition to take effect, I have to refresh the page a second time. Is there a way to have the condition take effect right away?
Heres some code:
[HttpPost]
public ActionResult Track(string email)
{
if (Request.Form["Email"] != null)
{
if (Request.Form["Email"] != "")
Tracker.Current.Session.IdentifyAs("email", Request.Form["email"]);
}
FillViewBag(); // for debugging to check if the contact is actualy identified.
//Remove from session to refresh the contact
var manager = Sitecore.Configuration.Factory.CreateObject("tracking/contactManager", true) as Sitecore.Analytics.Tracking.ContactManager;
manager.RemoveFromSession(Sitecore.Analytics.Tracker.Current.Contact.ContactId);
return View();
}
EDIT / SOLUTION
This is probably not the cleanest solution but changing return view()
to return Redirect("/page")
solved this for me