TheSwamp

Code Red => .NET => Topic started by: FELIX on January 10, 2017, 09:09:01 PM

Title: Find geographic location of user using IP address
Post by: FELIX 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
Title: Re: Find geographic location of user using IP address
Post by: kdub_nz 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 ?

Title: Re: Find geographic location of user using IP address
Post by: FELIX on January 11, 2017, 07:25:24 AM
I'm using VB Express 2010.