1

我已添加Cassette.Nancy到现有的 Nancy Web 项目中。这在我设置时工作正常,CassetteNancyStartup.OptimizeOutput = true;但是当设置为时,false我在非捆绑资源上得到 404。

这是我的设置。

我正在使用以下软件包:

  • Cassette.Nancy 版本="2.1.1"
  • 卡带版本="2.4.1"
  • 南希版本="0.22.2"
  • Nancy.Owin 版本="0.22.2"
  • Nancy.Viewengines.Razor 版本="0.22.2"

文件是这样的:

  • 内容
    • 文件1.css
    • 文件2.css
  • 脚本
    • script1.js
    • script2.js

卡带捆绑配置:

public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
{
    public void Configure(BundleCollection bundles)
    {
        bundles.AddPerSubDirectory<StylesheetBundle>("Content");
        bundles.Add<ScriptBundle>("Scripts");
    }
}

在我的_Layout.cshtml

@{
    Bundles.Reference("Content");
    Bundles.Reference("Scripts");
}

@Bundles.RenderStylesheets()
@Bundles.RenderScripts()

最后在Bootstrapper

public Bootstrapper()
{
    CassetteNancyStartup.OptimizeOutput = false;
}

就像我说的那样,当CassetteNancyStartup.OptimizeOutput设置为true但当false每个资源都返回像这样的 404 时,这可以正常工作:

GET http://localhost:10005/_cassette/asset/Content/file1.css?cf7a7edf515a8184a0c53ec498c583cc64bb0e63 404 (Not Found) 

有什么建议么?

4

1 回答 1

1

这个问题是因为我没有在web.config. 添加这个修复它。

  <system.webServer>
    <handlers>
      <add name="Owin" verb="*" path="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb" />
    </handlers>
  </system.webServer>
于 2014-04-11T19:21:32.350 回答