Anonymous profile initialization in Session start
My blog application uses an unusual way to measure anonymous visitors coming to the blog. First, I have turned anonymous identification ON in web.config. In anonymous profiles, I track the IP address of visitors in Session start (global.asax). And in a statistics component, I count the number of active profiles. Active profiles are visitors who are active in the last month.
After MVC3 was deployed, this feature stopped working. For some reasons, anonymous profiles were not initialized in Session start event handler in global.asax. So, the profile - HttpContext.Current.Profile was returning null.
After doing some research, I realized that the MVC controller was having the right profile object. Controllers have a property called Profile which exposes the anonymous profile object and this was working fine. As a workaround, I have used the profile object in the initialize method of the HomeController to initialize the anonymous profile. So, the active visitor count is working fine again.
I suspect not initializing the profile object (HttpContext.Current.Profile) in session start event is an unintended change from Microsoft.
Category : ASP.NET MVC