Blog from Saravanan Arumugam

Let us talk about Technologies

Category Archives: HTTP

HTTP could not register URL


From here on, I am going try to publish the exceptions/error messages I encounter during the programming and their corresponding resolution.

Exception

I wrote a self host in Visual Studio 2005 in Windows XP. It worked fine.

namespace CalculatorHost
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof(CalculatorService), 
                new Uri[] { new Uri("http://localhost:8080/Calculator") });
 
            host.AddServiceEndpoint(typeof(ICalculatorService), 
                new BasicHttpBinding(), "");
 
            ServiceMetadataBehavior behavior = 
                new ServiceMetadataBehavior();
            behavior.HttpGetUrl = new 
                Uri("http://localhost:8080/CalculatorService/Meta");
            behavior.HttpGetEnabled = true;
 
            host.Description.Behaviors.Add(behavior);
 
            host.Open();
            Console.WriteLine("Calculator Service Started!!!"+
                "\nPress enter to stop the service");
            Console.ReadLine();
            host.Close();
        }
    }
}
 

I tried to execute the same program in Visual Studio 2010 in Windows 7. But it gave the following exception.

HTTP could not register URL http://+:8080/CalculatorService/Meta/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

Note: I received the same exception for http://localhost:8080/Calculator as well.

Solution

The exception itself has offered helping hands on how to register Http Namespace by saying(see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

It takes us to the Microsoft’s title “Configuring HTTP and HTTPS”. The exception above resolved by following the solution under “Configuring Namespace Reservations”.

I ran the following command under the .Net Command Prompt.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>netsh http add urlacl url

=http://+:8080/CalculatorService/Meta/ user=\Everyone

Url reservation add failed, Error: 5

The requested operation requires elevation (Run as administrator).

I didn’t get through it yet, because by default the .Net command prompt doesn’t have access to register the Http Namespaces.

I reran the .Net command prompt in Administrator mode (Right Click the .Net Command Prompt in Start Menu, and select Run as Administrator).

The same command worked well in Administrator mode.

C:\Windows\system32>netsh http add urlacl url=http://+:8080/CalculatorService/Me

ta/ user=\Everyone

URL reservation successfully added

Another simple alternate to using netsh http command is to run the Visual Studio itself in Administrator mode.

Note: netsh is useful for a verity of work. Refer the following pages for more detail.

Netsh Command Reference

Netsh Commands for Hypertext Transfer Protocol (HTTP)

Advertisements