gpt4 book ai didi

Owin UseStaticFiles 不尊重 RequestPath

转载 作者:行者123 更新时间:2023-12-04 07:02:09 25 4
gpt4 key购买 nike

**编辑:注意:这似乎在 Owin StaticFiles 中间件的更高版本中得到修复,因此如果您有此问题,只需升级 **

我的 OWIN 配置有这个:-

   string root = AppDomain.CurrentDomain.BaseDirectory;
var staticFilesOptions = new StaticFileOptions();
staticFilesOptions.RequestPath = new PathString("/foo");
staticFilesOptions.FileSystem = new PhysicalFileSystem(Path.Combine(root, "web"));
app.UseStaticFiles(staticFilesOptions);

当我点击 /foo/app/app.js当我点击 /web/app/app.js 时,我收到 404 错误文件被返回。

怎么样 RequestPath旨在与 PhysicalFileSystem 一起工作?

最佳答案

我测试了这个代码片段,它对我有用 this sample project .

app.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/foo"),
FileSystem = new PhysicalFileSystem(@".\web"),
});

确保你的 web.config 中有这个:
<system.webServer>
...
<modules runAllManagedModulesForAllRequests="true"></modules>
...
</system.webServer>

关于Owin UseStaticFiles 不尊重 RequestPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22387555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com