cant start nancy self host without admin rights

My app uses Nancy Selfhosting. When I launch it without admin rights I get a System.Net.HttpListenerException "Access Denied".

Here is the code:

static void Main(string[] args)
    {   
        var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:80/"));
        nancyHost.Start();
        Application.Run();
    }

I have also tried different ports without success. Strangely, I dont get any Exceptions when launching a HttpListener that listens to the same Url. What could be causing this exception?

Answers


You will simply need Administrator permissions to run Nancy on your computer, or a user that is able to listen to a specific URL. This is to prevent malicious scripts from running services on your computer.

As an alternative solution you could take a look at this stackoverflow answer. It provides you with a simple way to restart your application with elevated permissions.


You need to set the self-host configuration to not rewrite the localhost route.

namespace NancyApplication1
{
    using System;
    using Nancy.Hosting.Self;

    class Program
    {
        static void Main(string[] args)
        {
            var uri =
                new Uri("http://localhost:3579");
            var config = new HostConfiguration();
            config.RewriteLocalhost = false;

            using (var host = new NancyHost(config, uri))
            {
                host.Start();

                Console.WriteLine("Your application is running on " + uri);
                Console.WriteLine("Press any [Enter] to close the host.");
                Console.ReadLine();
            }
        }
    }
}

I found this out by trying and failing a bit, but this page explains the reason behind.


Need Your Help

PyCrypto export/import of signature

python rsa signature pycrypto

created a client-server application with sockets and I am trying to transfer the signature from client to server. I convert it from tuple to string and then back to tuple. But signing stops working...

Embedding and HTML document in another: how do I make it auto-size?

html

I have a bunch of html help files and my boss wants them to be all in one giant file as well, for printing. I want to just embed them all into a single html page and I need the <object/> to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.