【问题标题】:Nancy on Owin doesn't serve static contentNancy on Owin 不提供静态内容
【发布时间】:2015-02-05 13:44:17
【问题描述】:

我在 Owin 上运行自托管的 Nancy Web 应用程序,但遇到静态内容问题。

假设我的应用程序从这个文件夹运行:

c:/我的文件夹/

我的观点在这里:

c:/myfolder/Manager/Views/

所以在我的浏览器中,我可以转到 http://localhost:85/Manager 并加载我的页面。

不过,我根本无法让它提供静态内容,我的所有文件都在 /Content 文件夹中,我试图将它同时放置到 /myfolder 和 /Manager 文件夹中,但没有成功。

http://localhost:85/Manager/Content/css/styles.csshttp://localhost:85/Content/css/styles.css 网址都不起作用

如何让它工作?

【问题讨论】:

    标签: owin nancy


    【解决方案1】:

    通过将这些代码行添加到Startup 来解决问题:

    using Microsoft.Owin.FileSystems; 
    using Microsoft.Owin.StaticFiles;
    
    ...
    
    var options = new FileServerOptions()
    {
        RequestPath = PathString.Empty,
        FileSystem = new PhysicalFileSystem("/Path/here")
    };
    app.UseFileServer(options);
    

    【讨论】:

      猜你喜欢
      • 2012-10-27
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 2019-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多