如何在asp.net核心剃须刀页面中启用CDN链接包

时间:2020-03-19 14:06:45

标签: c# asp.net-mvc asp.net-core razor-pages asp.net-core-3.0

当我将本地CSS用于捆绑软件时,它像这样正常工作

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ICacheHelper fillCache)
            {
                 app.UseBundling(bundles =>
                  {
                    bundles.AddCss("/Test.css")
                        .Include("~/css/sweetalert.min.css")
                        .Include("~/css/responsive.css");                
                });
            }

在Startup中。当我使用CDN链接捆绑其不起作用时,我得到一个空文件捆绑CSS。

 public IWebHostEnvironment webHost { get; }

        public Startup(IWebHostEnvironment webHostEnvironment)
        {            
            webHost = webHostEnvironment;
        }
  public void ConfigureServices(IServiceCollection services)
        {
            services.AddBundling()
              .UseDefaults(webHost)
              .UseNUglify();
        }

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ICacheHelper fillCache)
        {
             app.UseBundling(bundles =>
              {
                bundles.AddCss("/Test.css")
                    .Include("https://dk4umlpu.clo....ud.net/2.0/css/sweetalert.min.css")
                    .Include("https://dk4umlpu.clo....ud.net/2.0/css/responsive.css");                
            });
        }

0 个答案:

没有答案