简体   繁体   English

无法使System.Web.Optimization与Nancy Self Hosting一起运行

[英]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.

相关问题 获取对System.Web.Optimization中使用的URL的访问 - Get access to the URL's being used in System.Web.Optimization 要添加System.Web.Optimization错误 - System.Web.Optimization error to add 使用 System.Web.Optimization 捆绑,我如何访问构建捆绑的结果? - Using System.Web.Optimization Bundling, How Can I access The Result of a Built Bundle? ASP.NET System.Web.Optimization:捆绑jQueryUI CSS - ASP.NET System.Web.Optimization: Bundling jQueryUI CSS 如何避免在布局页面中使用“使用System.Web.Optimization” - How to avoid using “using System.Web.Optimization” in layout page 如何引用System.Web.Optimization程序集的1.1.0.0版 - How to reference version 1.1.0.0 of System.Web.Optimization assembly 为System.Web.Optimization安装了Nuget程序包,复制System.Web.Optimization.xml文件时不断出错。访问被拒绝 - Installed Nuget package for System.Web.Optimization, keep getting error copying the System.Web.Optimization.xml file.. access denied 可以在Kestrel上自托管剃刀Web应用程序的.NET Core应用程序可以在完整的.NET和参考system.web上运行吗? - Can a .NET Core app, self hosting razor web app on Kestrel, run on full .NET and reference system.web? 无法加载文件或程序集“System.Web.Optimization”或其依赖项之一 - Could not load file or assembly 'System.Web.Optimization' or one of its dependencies 有没有办法防止通过asp.net System.Web.Optimization 重命名某些变量 - Is there a way to prevent some variables being renamed via asp.net System.Web.Optimization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM