Skip to content

Commit 0fece60

Browse files
authored
Merge pull request #26 from skamphuis/feature/Issue_25
Fixes #25 Thanks Stefan!
2 parents b97b654 + f04584d commit 0fece60

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Controllers/VisitController.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ public VisitDTO ProcessVisit(VisitDTO visit)
417417
// get geo info based on IP
418418
if (!string.IsNullOrEmpty(visit.ip) && visit.ip != "127.0.0.1")
419419
{
420-
using (var objGeoIP2DB = new DatabaseReader(string.Concat(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\GeoIP2-City.mmdb")))
420+
try
421421
{
422-
try
422+
using (var objGeoIP2DB = new DatabaseReader(string.Concat(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\GeoIP2-City.mmdb")))
423423
{
424424
var objGeoIP2 = objGeoIP2DB.City(visit.ip);
425425

@@ -438,17 +438,17 @@ public VisitDTO ProcessVisit(VisitDTO visit)
438438
visit.latitude = objGeoIP2.Location.Latitude.ToString();
439439
visit.longitude = objGeoIP2.Location.Longitude.ToString();
440440
}
441-
catch
442-
{
443-
// IP address cannot be resolved
444-
}
441+
}
442+
catch
443+
{
444+
// IP address cannot be resolved
445445
}
446446
}
447447

448448
//get user agent properties using the 51Degrees database
449449
if (!string.IsNullOrEmpty(visit.user_agent))
450450
{
451-
var device = WebProvider.ActiveProvider.Match(visit.user_agent);
451+
var device = WebProvider.ActiveProvider?.Match(visit.user_agent);
452452
if (device != null)
453453
{
454454
if (device["IsMobile"] != null && device["IsMobile"].ToString() == "True")

0 commit comments

Comments
 (0)