I want to record the client that browse my web page, So I do this in Session_Start() of Global.asax
String ipAddress = System.Web. HttpContext.Current.Request.
ServerVariables["REMOTE_ADDR"];
Web.Models.WebsiteTracking web_track = new Web.Models.WebsiteTracking();
web_track.IDUser = 0;
web_track.ActiveLoginDate = DateTime.Now;
web_track.IPAddress = ipAddress;
this.DataContext.WebsiteTrackings.AddObject(web_track);
this.DataContext.SaveChanges();
I record the user’s IP address,the date that they browse and ID = 0 to table WebsiteTracking. But It error : Does not contain definition DataContext and no extend method ‘DataContext’.
Anyone can tell me, which thing that I have to replace with “this.DataContext”.
Thanks you so much.
Try creating a new instance of your
DataContext.