I'm trying to self host an OWIN pipeline in a WinForms application. The pipeline is hosting up both static files and Web Api v2 content. The implementation is working great locally, but I'm not sure what I'm missing in order to be able to access the hosted files and APIs from remote machines on my network.
For simplicity sake, I downloaded the sample self-host app from codeplex here and tried accessing the test methods remotely after making the below modifications to the base address (I tried both running the netsh regisration and I'm running in Admin mode) and I still can't access them. What do I need to change in the configuration to be able to view the 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 Startup Configuration, pretty basic stuff:
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);
}
}