1.webapi默认没有wwwroot 建立一个就行了
2.在stratup.cs的Configure事件中增加下面的代码
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions(); defaultFilesOptions.DefaultFileNames.Clear(); defaultFilesOptions.DefaultFileNames.Add("index.html"); app.UseDefaultFiles(defaultFilesOptions); StaticFileOptions staticFileOptions = new StaticFileOptions(); staticFileOptions.FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(@"E:KaoshiWebAPIwwwroot"); app.UseStaticFiles(staticFileOptions);//开启静态文件