本文介绍了无法使System.Web.Optimization与Nancy Self Hosting一起运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

使用Nancy Self Hosting使用System.Web.Optimization的人有幸吗?如果我注释掉"Styles.Render(〜/csspack/logincss").ToString(),该视图将正常运行.如果我将其留在空白页中,则会发送到浏览器.

Has anyone had any luck using System.Web.Optimization with Nancy Self Hosting?If I comment out "Styles.Render("~/csspack/logincss").ToString()" the view works fine.If I leave it in a blank page is sent to the browser.

这是我的Razor配置的样子.

This is what my Razor config looks like.

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/

I couldn't get this to work, so I ended up switching to Cassette.http://getcassette.net/

毫无问题地工作了.真的不必变化很大.看起来System.Web.Optimization是从Cassette借来的.

Worked right out of the gate with no issues. Didn't really have tochange much. Looks like System.Web.Optimization borrowed a lot from Cassette.

更新
在Linux上运行时,Cassette给了我奇怪的性能问题和错误.我最终只是建立自己的. https://github.com/donnyv/Nancy.BundleIt

Update
Cassette was giving me weird performance issues and errors when running on Linux.I ended up just building my own. https://github.com/donnyv/Nancy.BundleIt

这篇关于无法使System.Web.Optimization与Nancy Self Hosting一起运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 16:44