如何使用绝对路径提供除 wwwroot
以外的文件夹?该文件夹位于我本地机器上的不同驱动器上。我收到此错误:
''value'中的路径必须以'/'开头。'
这是我的 Starup.cs
Configure()
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(@"E:\path\to\folder\"),
RequestPath = new PathString("\\stuff")
});
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
答案 0 :(得分:1)
RequestPath
指的是从应用程序中提供内容的路径,因此它需要以 /
开头:
RequestPath = new PathString("/stuff")