Search code examples
c#asp.net-mvcanalytics

What request info to log in an ASP.Net MVC application


I'm not concerned with logging for defect fixing, but more for google-like analytics. Does anyone have a killer schema that they use to make analytics easier. I'd prefer to have control over the analytics on my site and am looking for good practices/ideas/implementations.


Solution

  • I would first look at the properties available in the current HttpRequest class such as:

    • HttpMethod
    • Path
    • PathInfo
    • QueryString
    • RawUrl
    • UrlReferrer
    • UserAgent

    You may also want to record, if applicable:

    HttpSessionState.SessionID

    You could then log the information you need into a database for every request for later analysis. How you analyse the data depends on what you want to know.