Question: My site is done in ASP .NET MVC and SQL Server. I want to add a view counter feature for details page of each products in my e-ccommerce site,that is number of total hits to a page. Which is the best way to achieve this without affecting the current performance in the loading of the page .?

Answer: 
if you just want to keep track of hits you can do as mercsen said in his second comment,

if you want to display the number of hits on the product details page then you can write an ajax request which fetches the counter periodically
Using cookie:

```
var productId = 1;

if (Request.Cookies["ViewedPage"] != null)
{
    if (Request.Cookies["ViewedPage"][string.Format("pId_{0}",productId )] == null)
    {
        HttpCookie cookie = (HttpCookie)Request.Cookies["ViewedPage"];
        cookie[string.Format("pId_{0}",productId )] = "1";
        cookie.Expires = DateTime.Now.AddDays(1);
        Response.Cookies.Add(cookie); 

        db.Execute("UPDATE Products SET ViewCount = ViewCount + 1 WHERE ProductId = @id", new { id = productId } ); 
        db.SaveChanges();
    }
}
else
{
    HttpCookie cookie = new HttpCookie("ViewedPage");
    cookie[string.Format("pId_{0}",productId )] = "1";
    cookie.Expires = DateTime.Now.AddDays(1);
    Response.Cookies.Add(cookie); 

    db.Execute("UPDATE Products SET ViewCount = ViewCount + 1 WHERE ProductId = @id", new { id = productId } ); 
    db.SaveChanges();
}

```