Web API Self-Service Client Configuration

I managed to run my own WEP-API using OWIN in a console application, running it using code like this:

//string baseAddress = "http://192.168.1.6:8111/";
string baseAddress = "http://+:8111/";

// Start OWIN host 
using (Microsoft.Owin.Hosting.WebApp.Start<Startup>(url: baseAddress))
{
    Console.ReadLine();
}

Using and registering an address, such as " http: // +: 9000 / " on the main service machine, the idea was to use a common IP address for the host, which will not affect clients when the host IP address can change.

Clients are located on machines other than those on which the service is running. Something like a mobile phone from the local network or another laptop from the local network, and in the future, if possible, also outside the local network.

In my self-service client, which is an html page, I have JavaScript code, for example:

//var uri = 'http://192.168.1.6:8111/api/tests';
var uri = 'http://+:8111/api/tests';

function Read()
{
    $.getJSON(uri + '/' + id)
}

IP- , WEB-, " http://+:9000/api/tests" .

, ​​ ? - , IP- ?

, IP- , , IP- - .

+6
2

, IP-.

, : hostname

, myhost. http://myhost:8111 .

DNS. VPN, .

+9

, , , , , , IP-, DNS , http 8111, .

, javascript, . IP- 8111. . ?

, , javascript, , . , :

  • uri javascript : var uri = '/api/tests';
  • javascript Request.Url.Authority , -, javascript. - , , javascript.

, , , api/test/{id}.

+2

All Articles