Kuubs
Kuubs

Reputation: 1340

Cannot use multiple options OWIN

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.

Upvotes: 2

Views: 1214

Answers (1)

Kuubs
Kuubs

Reputation: 1340

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>

Upvotes: 1

Related Questions