2

I've got a small problem regarding a server hosted with OWIN. I'm trying to make it accessible to the local network which means I have to add a few extra options:

// Start OWIN host 
        StartOptions options = new StartOptions();
        options.Urls.Add("http://localhost:4004");
        //options.Urls.Add("http://127.0.0.1:4004");
        //options.Urls.Add(string.Format("http://{0}:4004", Environment.MachineName));
        using (WebApp.Start<Startup>(options))
        {

            // Create HttpCient and make a request to api/values 
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/text"));

        }

Now the problem is, if I uncomment the second line:

options.Urls.Add("http://127.0.0.1:4004");

I'll get an error:

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.

Can someone help me out? It's weird that I can only use localhost, and not my ip.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Kuubs
  • 1,300
  • 1
  • 14
  • 42
  • According to this: http://stackoverflow.com/questions/16642651/self-hosted-owin-and-urlacl your code looks fine. Are there any more details in exceptions? Like inner exception or something. – Panu Oksala Feb 15 '15 at 18:12
  • @Mino yes, there is an inner exception: "Acces is denied" – Kuubs Feb 16 '15 at 20:37

1 Answers1

1

The problem lies in the fact that there is no admin rights. I get an acces denied inner exception. With the use of this in a manifest application file I've made the error go away :)

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
  </requestedPrivileges>
</security>

Kuubs
  • 1,300
  • 1
  • 14
  • 42