Web API Core | ComponentOne
Services / Visitor API / Configuring IP2Location Database
In This Topic
    Configuring IP2Location Database
    In This Topic

    Visitor API has built-in provider to find visitor's location based on their IP Address.

    To configure the IP2Location Database, you need add the following code to the Startup.cs file in your Web API application.

    C#
    Copy Code
    public void ConfigureServices(IServiceCollection services)
    {
        // ...     
        services.ConfigureVisitor(builder =>
        {
            builder.UseIp2Location(*ip2LocationConnectionString*);
        });
    }
    

    As shown in the code above, Visitor API requires a ConnectionString to the Ip2Location database. It works with ip-country-region-city-latitude-longitude-zipcode-timezone database and MS SQL server. You can easily set up the database by following their instructions.

    Note: The LITE edition is an open-source version of database with limited accuracy & number of records compares to commercial release. It is free for personal or commercial use with attribution required by mentioning the use of this data as follows:
    This product includes IP2Location LITE data available from IP2Location.