public ContentResult RunDiagnostics() { var diag = new StringBuilder(); try { Debug.WriteLine("RunDiagnostics(): START"); string currentIP = IpHelper.GetIPAddress(HttpContext.Request); string testingIP = "13.82.179.176"; Debug.WriteLine("RunDiagnostics(): Current IP: " + currentIP); Debug.WriteLine("RunDiagnostics(): Testing IP: " + testingIP); diag.AppendLine("Current IP: " + currentIP); diag.AppendLine("Testing IP: " + testingIP); var locTesting = GeoLocationHelper.GetLocationFromIp(IPAddress.Parse(testingIP)); // Geolocation not configured or not working if (locTesting == null) { diag.AppendLine("GeoLocation: Not working! Please configure Maxmind or another GeoIP provider"); return(Content(diag.ToString(), "text/plain")); } else { var locCurrent = GeoLocationHelper.GetLocationFromIp(IPAddress.Parse(currentIP)); string psCurrent = HttpHelper.GetSegmentList(GeoLocationHelper.GetCoordinatesFromIp(IPAddress.Parse(currentIP))); Debug.WriteLine("RunDiagnostics(): GeoLocation (current IP): {0} - {1}", locCurrent.CountryCode, locCurrent.Region); Debug.WriteLine("RunDiagnostics(): Segments (current IP): " + psCurrent); diag.AppendLine("GeoLocation (current IP): " + locCurrent.CountryCode + " - " + locCurrent.Region); diag.AppendLine("Segments (current IP): " + psCurrent); string psTesting = HttpHelper.GetSegmentList(GeoLocationHelper.GetCoordinatesFromIp(IPAddress.Parse(testingIP))); Debug.WriteLine("RunDiagnostics(): GeoLocation (testing IP): {0} - {1}", locTesting.CountryCode, locTesting.Region); Debug.WriteLine("RunDiagnostics(): Segments (testing IP): " + psTesting); diag.AppendLine("GeoLocation (testing IP): " + locTesting.CountryCode + " - " + locTesting.Region); diag.AppendLine("Segments (testing IP): " + psTesting); Debug.WriteLine("RunDiagnostics(): END"); return(Content(diag.ToString(), "text/plain")); } } catch (Exception ex) { Debug.WriteLine("RunDiagnostics(): Error: " + ex.Message); diag.AppendLine("Error while running diagnostics" + ex.Message); return(Content(diag.ToString(), "text/plain")); } }