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.