Owin UseStaticFiles不遵守RequestPath [英] Owin UseStaticFiles not respecting RequestPath
本文介绍了Owin UseStaticFiles不遵守RequestPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
**注意:这似乎在更高版本的Owin StaticFiles中间件中已解决,因此,如果您有此探针,只需升级**
** NOTE: This appears to be fixed in later versions of the Owin StaticFiles middleware, so if you have this probem, simply upgrade **
我的OWIN配置具有以下内容:-
My OWIN configuration has this:-
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
时,我遇到404错误,当我点击/web/app/app.js
时,文件被返回.
When I hit /foo/app/app.js
I get a 404 error, when I hit /web/app/app.js
the file is returned.
RequestPath
是如何与PhysicalFileSystem
一起工作的?
How is RequestPath
meant to work in conjunction with PhysicalFileSystem
?
推荐答案
I tested this code snippet and it works for me from this sample project.
app.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/foo"),
FileSystem = new PhysicalFileSystem(@".\web"),
});
确保您的web.config中包含此文件:
Make sure you have this in your web.config:
<system.webServer>
...
<modules runAllManagedModulesForAllRequests="true"></modules>
...
</system.webServer>
这篇关于Owin UseStaticFiles不遵守RequestPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文