有没有人有幸使用System.Web.Optimization和Nancy主机?如果我注释掉"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 ....发布于 2014-05-14 15:23:40
我无法让这个工作,所以我最终切换到盒式磁带。http://getcassette.net/
毫无问题地走出了大门。没必要改变太多。看来System.Web.Optimization从录音带里借了很多东西。
更新
在Linux上运行时,盒式磁带给我带来了奇怪的性能问题和错误。最后我只是在建造自己的房子。https://github.com/donnyv/Nancy.BundleIt
https://stackoverflow.com/questions/23003482
复制相似问题