2014-04-11 41 views
2

有沒有人使用過Nancy Self Hosting的System.Web.Optimization有任何運氣? 如果我註釋掉「Styles.Render(」〜/ csspack/logincss「)。ToString()」視圖正常工作。 如果我把它留在空白頁面發送給瀏覽器。無法獲得System.Web.Optimization與Nancy Self Hosting一起運行

這就是我的Razor配置的樣子。

public class RazorConfig : IRazorConfiguration 
{ 
    public IEnumerable<string> GetAssemblyNames() 
    { 
     yield return "Microsoft.Web.Infrastructure"; 
     yield return "WebGrease"; 
     yield return "System.Web.Optimization"; 
     yield return "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; 
    } 

    public IEnumerable<string> GetDefaultNamespaces() 
    { 
     yield return "Microsoft.Web.Infrastructure"; 
     yield return "WebGrease"; 
     yield return "System"; 
     yield return "System.Web"; 
     yield return "System.Web.Optimization"; 
     yield return "Nancy.ViewEngines.Razor"; 
    } 

    public bool AutoIncludeModelNamespace 
    { 
     get { return false; } 
    } 
} 

我在這樣的啓動註冊它。

protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) 
{ 
      container.Register<IRazorConfiguration, RazorConfig>().AsSingleton(); 

      container.Register<RazorViewEngine>(); 

      .....bundle code... 
} 

這是我的看法。

inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic> 
@using Nancy.Helpers 
@using System.Web.Optimization 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<head> 
    <meta charset="utf-8" /> 
    <title>Log In</title> 
    @Html.Raw(Styles.Render("~/csspack/logincss").ToString()) 
</head> 
.... more html .... 
+0

不應該只是'@ Styles.Render(「〜/ csspack/logincss」)''沒有'@ Html.Raw'或'ToString()'? –

+0

你遺漏了最重要的信息 - 你得到的錯誤 – TheCodeJunkie

+1

@ArtyomNeustroev如果你在Asp.net中工作,但是在南希你必須添加它。 –

回答

1

我不能得到這個工作,所以我最終切換到卡帶。 http://getcassette.net/

工作沒有問題的大門。沒有真的要 變化很大。看起來像System.Web.Optimization借鑑了Cassette很多。

更新在Linux上運行時
盒給我奇怪的性能問題和錯誤。 我最終只是建立自己的。 https://github.com/donnyv/Nancy.BundleIt

+0

好吧,我還沒有能夠得到它運行,可能與緩慢或卡斯特,謝謝! –