![](/img/trans.png)
[英]Get access to the URL's being used in System.Web.Optimization
[英]Can't get System.Web.Optimization to run with Nancy Self Hosting
有人在使用Nancy Self Hosting的System.Web.Optimization時有運氣嗎? 如果我注釋掉“ Styles.Render(“〜/ csspack / logincss”)。ToString()“,該視圖將正常運行。 如果我將其留在空白頁中,則會發送到瀏覽器。
這就是我的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 ....
我無法使它正常工作,所以我最終切換到了Cassette。 http://getcassette.net/
毫無問題地工作了。 其實並沒有太大的改變。 看起來System.Web.Optimization從Cassette借來了很多東西。
更新
在Linux上運行時,Cassette給了我奇怪的性能問題和錯誤。 我最終只是建立自己的。 https://github.com/donnyv/Nancy.BundleIt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.