gpt4 book ai didi

c# - OWIN自静态文件服务器多路由

转载 作者:行者123 更新时间:2023-11-30 20:31:54 48 4
gpt4 key购买 nike

我在我的 Owin 中配置了一个 webApi 和一个静态文件服务器来获取我的应用程序中需要的一些文件。

public void Configuration(IAppBuilder application)
{
//Other middlewares and configurations
....
application.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/myPath1/public"),
FileSystem = new PhysicalFileSystem(m_FolderPathProvider.myPath1FolderPublic)
});

// Attribute routing.
.....
}

这就像一个魅力。我需要的是为另一个路径和另一个不同的物理文件夹声明另一个 FileServer。我害怕的是,如果我以同样的方式做,我将覆盖这个,我将只有一个。那么如何声明第二个文件服务器呢?

谢谢。

最佳答案

AFAICT,您可以使用您已经在使用的相同重载将不同的文件系统路径“挂载”到不同的路径上。

public void Configuration(IAppBuilder application)
{
//Other middlewares and configurations
....
application.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/myPath1/public"),
FileSystem = new PhysicalFileSystem(m_FolderPathProvider.myPath1FolderPublic)
});

application.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/myPath2/public"),
FileSystem = new PhysicalFileSystem(m_FolderPathProvider.myPath2FolderPublic)
});

// Attribute routing.
.....
}

如果你想合并它们,我认为使用 UseFileServer 是不可能的。

我错过了什么吗?

关于c# - OWIN自静态文件服务器多路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42386190/

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