【问题标题】:OWIN self static file server multiple routesOWIN自静态文件服务器多路由
【发布时间】:2017-07-12 04:32:57
【问题描述】:

我已经在我的 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。我害怕的是,如果我以同样的方式进行操作,我将覆盖这个,而我将只有一个。那么如何声明第二个文件服务器呢?

谢谢。

【问题讨论】:

    标签: c# asp.net owin katana


    【解决方案1】:

    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 是不可能的。

    我错过了什么吗?

    【讨论】:

    • 不,你没有错过什么,我的问题听起来很愚蠢,但我尝试了这种方法并没有奏效。一定是我的一般解决方案,因为我在不同的隔离解决方案中尝试了这个并且工作正常。所以谢谢你:)
    猜你喜欢
    • 2014-07-28
    • 1970-01-01
    • 2016-04-20
    • 2013-06-12
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    • 2016-12-12
    • 1970-01-01
    相关资源
    最近更新 更多