I'm trying to create the simplest possible ASP.NET 5 project to serve static files, without depending on Visual Studio project templates. However, when I request a file, I'm only receiving an empty response. Here's my code:
project.json:
{
"wwwroot": "wwwroot",
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx46": { }
}
}
Startup.cs:
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
namespace Study.StaticFileServer
{
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
}
}
}
Finally, there's a "wwwroot" folder containing "downloadme.txt".
When I run dnx web
and request the file, the response is blank. What must I add to get this to work?
It was hard to spot but there is an error in project.json
. Change wwwroot
to webroot
Current:
{
"wwwroot": "wwwroot",
[...]
Should be:
{
"webroot": "wwwroot",
[...]
The webroot
points to root of an application where static files are taken from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With