Self Hosting OWIN for other computers on the network

I am trying to place the OWIN pipeline myself in a WinForms application. The pipeline hosts both static files and Web Api v2 content. The implementation works fine in place, but I'm not sure what I'm missing to have access to hosted files and APIs from remote computers on my network.

For simplicity, I downloaded a sample application for my own host from codeplex here and tried to access the test methods remotely after making the following changes to the base address (I tried how to run netsh regisration, so I start in administrator mode), and I still haven't I can access them. What do I need to change in the configuration in order to be able to view content from other computers on the same network?

static void Main() { string baseAddress = "http://*:10281/"; // Start OWIN host using (WebApp.Start<Startup>(url: baseAddress)) { // Create HttpCient and make a request to api/values HttpClient client = new HttpClient(); HttpResponseMessage response = client.GetAsync("http://localhost:10281/api/values").Result; Console.WriteLine(response); Console.WriteLine(response.Content.ReadAsStringAsync().Result); Console.ReadLine(); // Keeps the host from disposing immediately } } 

Here's the launch configuration, a fairly simple piece of material:

 public class Startup { // This code configures Web API contained in the class Startup, which is additionally specified as the type parameter in WebApplication.Start public void Configuration(IAppBuilder appBuilder) { // Configure Web API for Self-Host HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); appBuilder.UseWebApi(config); } } 
+6
source share
1 answer

This code looks great, and there is no reason why it should not work, especially if you can access the OWIN server locally.

There are two likely problems that prevent access to the network. Either you need to add an incoming rule to the Windows firewall for port 10281 (or temporarily disable any firewalls on the host computer), or your network somehow blocks traffic.

+6
source

All Articles