[英]Can't get System.Web.Optimization to run with Nancy Self Hosting
Has anyone had any luck using System.Web.Optimization with Nancy Self Hosting? 有人在使用Nancy Self Hosting的System.Web.Optimization时有运气吗? If I comment out "Styles.Render("~/csspack/logincss").ToString()" the view works fine.
如果我注释掉“ Styles.Render(“〜/ csspack / logincss”)。ToString()“,该视图将正常运行。 If I leave it in a blank page is sent to the browser.
如果我将其留在空白页中,则会发送到浏览器。
This is what my Razor config looks like. 这就是我的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; }
}
}
I registered it in startup like this. 我是这样注册的。
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
container.Register<IRazorConfiguration, RazorConfig>().AsSingleton();
container.Register<RazorViewEngine>();
.....bundle code...
}
This is my view. 这是我的看法。
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 ....
I couldn't get this to work, so I ended up switching to Cassette. 我无法使它正常工作,所以我最终切换到了Cassette。 http://getcassette.net/
http://getcassette.net/
Worked right out of the gate with no issues. 毫无问题地工作了。 Didn't really have to change much.
其实并没有太大的改变。 Looks like System.Web.Optimization borrowed a lot from Cassette.
看起来System.Web.Optimization从Cassette借来了很多东西。
Update 更新
Cassette was giving me weird performance issues and errors when running on Linux. 在Linux上运行时,Cassette给了我奇怪的性能问题和错误。 I ended up just building my own.
我最终只是建立自己的。 https://github.com/donnyv/Nancy.BundleIt
https://github.com/donnyv/Nancy.BundleIt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.