unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.46k stars 176 forks source link

.WithStaticFolder() not working #522

Closed sebastianraese closed 3 years ago

sebastianraese commented 3 years ago

Describe the bug While trying to serve a set of static HTML files with version 3.4.3 on Windows, I am getting an unexpected 404 error. The server itself is up and running.

To Reproduce

  1. Create a folder (e.g. ''D:\htmlroot') containing an 'index.html' file
  2. Setting up the server: WebServer output = new WebServer(server => server.WithUrlPrefix("http://localhost:1234").WithMode(HttpListenerMode.Microsoft)); output.WithStaticFolder("/","D:\htmlroot",true);

Expected behavior When requesting 'http://localhost:1234/index.html' the page's HTML content shall be returned.

Desktop:

sebastianraese commented 3 years ago

Issue found myself: When registrating some WebAPI controllers prior to the static folder, there might be a conflict if using '/' as root URL for both. In that case, the WebApi controller is tried to be applied first/ only - obviously not working with the 'index.html' request.