I am trying to set up Application Insights on an ASP.NET MVC Web Application and I am not certain on the setup required.
I have added the Application Insights Telemetry SDK for Services NuGet package to my project in Visual Studio 2012.
Can someone confirm if I need both the JavaScript in my HTML:

AND the following code in Global.asax:
protected void Application_BeginRequest(object sender, EventArgs e)
{
ServerAnalytics.BeginRequest();
ServerAnalytics.CurrentRequest.LogEvent(
Request.Url.AbsolutePath);
}
I currently have both added to the project and I am getting some usage information, but it is not accurate (0 unique users for example).
I was also getting performance data, but this is no longer happening.
I have been using the links below for reference:
http://msdn.microsoft.com/en-us/library/dn481094.aspx
http://msdn.microsoft.com/en-us/library/dn495324.aspx
http://msdn.microsoft.com/en-us/library/dn518124.aspx
http://msdn.microsoft.com/en-us/library/dn481098.aspx
I would say it depends on your tasks. Use only Javascript code snippet if you need to log event on Client side but use ServerAnalytics.CurrentRequest.LogEvent() if you want to write event on Server side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With