0

I use HttpSelfHostServer and I want to bind it on unique specified prefix.

public StatServer(string prefix)
{
    if (string.IsNullOrEmpty(prefix))
    {
        Console.WriteLine("Can't use empty prefix");
        return;
    }
    var configuration = new HttpSelfHostConfiguration(new Uri($"http://perchik:8080"))
    {
        HostNameComparisonMode = HostNameComparisonMode.Exact
    };
    SetRoutes(configuration);
    configuration.Formatters.Clear();
    var jsonMediaTypeFormatter = new JsonMediaTypeFormatter {Indent = true};
    configuration.Formatters.Add(jsonMediaTypeFormatter);
    configuration.Formatters.Add(new FormUrlEncodedMediaTypeFormatter());
    _server = new HttpSelfHostServer(configuration);
}

Before I start the StatServer I run command as Administrator: "netsh http add urlacl url=http://+:8080/ user=machine\user"

And "ERR_NAME_NOT_RESOLVED" is appear when i try "http://perchik:8080/controller/id" or "http://localhost:8080/controller/id".

I want to use prefix like perchik-placeholder, but nor random prefix neizer perchik-word doesn't work P.S.

If I remove HostNameComparisonMode = HostNameComparisonMode.Exact line from code above: "http://perchik:8080/controller/id" is still not worked, but "http://localhost:8080/controller/id" is worked.

Bengi Besçeli
  • 3,638
  • 12
  • 53
  • 87
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
  • What line of code causes the problem? What happens if you go to command prompt and ping `perchik`? – theMayer Mar 07 '17 at 18:58
  • @theMayer not only one line of code cause the problem. Problem is `BaseAddress` from `HttpSelfHostServer` is set as expected to `http://perchik:8080`, but browser says "ERR_NAME_NOT_RESOLVED" – murzagurskiy Mar 07 '17 at 19:03
  • That would lead to the conclusion that you have a DNS problem, not a programming problem. – theMayer Mar 07 '17 at 19:17
  • @theMayer and what I need to check? – murzagurskiy Mar 08 '17 at 07:30
  • I really have no idea - but the DNS service resolves names, so you might start by looking into DNS configuration on whatever platform you are using. – theMayer Mar 08 '17 at 22:20

0 Answers0