public EmptyResult Track() { string userId = null; if (User.Identity.IsAuthenticated) { userId = User.Identity.GetUserId(); } var ip = Request.UserHostAddress; Guid?id = null; if (Request.Cookies["VisitorId"] != null) { Guid cookieVal; if (Guid.TryParse(Request.Cookies["VisitorId"].Value, out cookieVal)) { id = cookieVal; } } id = visitorService.TrackVisitor(id, userId, ip); Response.SetCookie(new HttpCookie("VisitorId", id.ToString()) { Expires = DateTime.Now.AddDays(30) }); return(new EmptyResult()); }