Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix a AutomaticUrlReservationCreationFailureException when using Nancy FX Self Host

Tags:

netsh

nancy

When using Nancy FX, I came across the following exception which was thrown when trying to fire up a web service: AutomaticUrlReservationCreationFailureException

Having looked into it in a bit more detail, I discovered that the way to fix this was to run up a cmd prompt (as an administrator), then run the following command:

netsh http add urlacl url=http://+:1234/ user=DOMAIN\username

where

  • DOMAIN\username is the id of the user the service will be run under
  • 1234 is the port that the service will be run on

I write this here in case anyone else comes across the same issue and spends a fruitless half hour or so looking for an answer - hopefully they will find this sooner than I did!

like image 976
Charlie_ Avatar asked Aug 21 '13 22:08

Charlie_


2 Answers

If you're creating your own NancyFx host, it may be easier for you to flag your HostConfiguration this way

HostConfiguration hostConfigs = new HostConfiguration()
{
    UrlReservations = new UrlReservations() { CreateAutomatically = true }
};

or...

HostConfiguration hostConfigs = new HostConfiguration();
hostConfigs.UrlReservations.CreateAutomatically = true;

And then finally have something like

NancyHost nancyHost = new NancyHost(new Uri("http://+:80"), new DefaultNancyBootstrapper(), hostConfigs);
like image 155
Victor K Masiror Avatar answered Nov 28 '22 20:11

Victor K Masiror


The Message of the AutomaticUrlReservationCreationFailureException will tell you this

The Nancy self host was unable to start, as no namespace reservation existed for the provided url(s).

Please either enable CreateNamespaceReservations on the HostConfiguration provided to the NancyHost, or create the reservations manually with the (elevated) command(s):

http add urlacl url=http://+:8888/nancy/ user=Everyone
http add urlacl url=http://127.0.0.1:8888/nancy/ user=Everyone
http add urlacl url=http://+:8889/nancytoo/ user=Everyone

The suggested reservations is based on the base URIs that you pass into the host when you create it.

like image 32
TheCodeJunkie Avatar answered Nov 28 '22 22:11

TheCodeJunkie