Author Topic: Find geographic location of user using IP address  (Read 1821 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 241
Find geographic location of user using IP address
« on: January 10, 2017, 09:09:01 PM »
From a code I found in VB.NET to ASP.NET I'm trying to adapt to use in a DLL in AutoCAD. What is shown in yellow does not compile.

Code - vb.net: [Select]
  1. Imports Autodesk.AutoCAD.Runtime
  2. Imports System.Net
  3. Imports System.Collections.Generic
  4. Imports System.Web.Script.Serialization
  5.  
  6. Public Class IPGEO
  7.     Implements IExtensionApplication
  8.     Private Sub Initialize() Implements IExtensionApplication.Initialize
  9.     End Sub
  10.     Private Sub Terminate() Implements IExtensionApplication.Terminate
  11.     End Sub
  12.     <CommandMethod("IPGEO")> _
  13.     Public Sub IPGEO()
  14.         Dim ipAddress As String = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  15.         If String.IsNullOrEmpty(ipAddress) Then
  16.             ipAddress = Request.ServerVariables("REMOTE_ADDR")
  17.         End If
  18.         '
  19.         Dim APIKey As String = "<Your API Key>"
  20.         Dim url As String = String.Format("http://api.ipinfodb.com/v3/ip-city/?key={0}&ip={1}&format=json", APIKey, ipAddress)
  21.         '......
  22.     End Sub
  23. End Class
  24.  

edit:kdub -> remove hardcoded post colors and add line coloring in   code=vbnet,4,14,16
« Last Edit: January 10, 2017, 10:31:43 PM by kdub »
OK.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: Find geographic location of user using IP address
« Reply #1 on: January 10, 2017, 10:38:03 PM »

Wild assed guess:
How does your Method IPGEO know what the Request is ?

What is the actual compile error message ... does that give you a hint ?

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

FELIX

  • Bull Frog
  • Posts: 241
Re: Find geographic location of user using IP address
« Reply #2 on: January 11, 2017, 07:25:24 AM »
I'm using VB Express 2010.
OK.