I can only serve one file with OWIN UseStaticFiles
.net, owin
Solution
I think I know what is going wrong: The 3rd party frameworks that you are using are either in alpha or beta. You should not rely on them based on you experience with them and their general state.
I created an almost identical setup (link to project files) and saw the exact same results. The used libraries are just not up to the task yet.
Edit:
I could get it to run much more relaibly with version 0.23.20815.0 of the Microsoft.Owin.StaticFiles library. I built it myself from the latest Katana sources. You can find my latest code at my GitHub page.
Problem
I'm using OWIN to be able to serve static content over http from within a Windows Service. (To embed a Web Administration Tool for the Windows Service). I experience some strange behaviour: - When I run the service, I can only access one file that is in the "web" folder, every consecutive call results in the browser telling that the page is not available (ERR_CONNECTION_RESET). - The embedded WebApi stays accessible. - When I restart the service with the same address and port, the files stay invisible. - When I restart the service on another port, I can access a file once... By the way, this files in this "web" folder are set to "Copy always" for the "Copy to Output Directory" property. Anyone knows what is going wrong? See here my StartUp configuration class ``` public class WebStartUp { public void Configuration(IAppBuilder app) { string staticFilesDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "web"); app.UseStaticFiles(staticFilesDir); HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); app.UseWebApi(config); } } ``` See here my Windows Service that hosts it... ``` public partial class MyService : ServiceBase { private IDisposable webApp; private const string ServiceAddress = "http://localhost:2345"; public MyService() { } protected override void OnStart(string[] args) { InternalStart(); } internal void InternalStart() { webApp = WebApp.Start<WebStartUp>(url: ServiceAddress); } protected override void OnStop() { } public static void Main() { #if DEBUG var service = new MyService(); Console.WriteLine("starting"); service.InternalStart(); Console.ReadLine(); #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new RaceManagerService(); } ServiceBase.Run(ServicesToRun); #endif } } ```