发布的WebForms应用时捆绑缩小不工作 [英] Bundle Minification not working when publishing WebForms App

查看:172
本文介绍了发布的WebForms应用时捆绑缩小不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用捆绑的缩小对于一些.css和.js文件。我的包的配置如下:

I'm trying to use bundle minification for some .css and .js files. My bundle config is the following:

public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/Modernizr").Include(
            "~/Scripts/modernizr.js"
        ));

        bundles.Add(new StyleBundle("~/TemplateContent").Include(
            "~/Content/bootstrap.css",
            "~/Content/bootstrap-responsive.css",
            "~/Content/prettyPhoto.css",
            "~/Content/prettify.css",
            "~/Content/flexslider.css",
            "~/Content/iview.css",
            "~/Content/style.css",
            "~/Content/default.css"
        ));

        bundles.Add(new StyleBundle("~/AppContent").Include(
            "~/Content/bootstrap-tablesorter.css",
            "~/Content/animate.css",
            "~/Content/font-awesome.css",
            "~/Content/jcarousel.css",
            "~/Conten/overwrite.css",
            "~/Content/sequence.css",
            "~/Content/sequence.ie.css",
            //more styles
        ));

        bundles.Add(new ScriptBundle("~/TemplateScripts").Include( 
            "~/Scripts/modernizr-*",
            "~/Scripts/jquery.js",
            "~/Scripts/raphael.js",
            "~/Scripts/jquery.easing.1.3.js",
            "~/Scripts/bootstrap.js",
            "~/Scripts/google-code-prettify/prettify.js",
            "~/Scripts/jquery.elastislide.js",
            "~/Scripts/jquery.tweet.js",
            "~/Scripts/jquery.prettyPhoto.js",
            "~/Scripts/jquery.flexslider.js",
            "~/Scripts/iview.js",
            "~/Scripts/jquery-hover-effect.js",
            "~/Scripts/animate.js",
            "~/Scripts/custom.js"
        ));

        bundles.Add(new ScriptBundle("~/AppScripts").Include(
            "~/Scripts/jquery.ticker.js",
            "~/Scripts/jquery.contenthover.js",
            "~/Scripts/jquery-ui-1.10.3.js",
            "~/Scripts/datetimepicker.js",
            "~/Scripts/jquery.metadata.js",
            //more scripts
        ));

        BundleTable.EnableOptimizations = true;
}

当我发布应用服务器(GoDaddy的共享虚拟主机的问题发生),我得到一个缩小的输出,但我得到关于这些产出403错误。

The problem happens when I publish the app to a server (godaddy shared web hosting), I do get a minified output, but I get 403 errors on those outputs.

如果我设置

BundleTable.EnableOptimizations = false;



该文件不会缩小的,但页面有正确的行为。

The files are not minified but the page has the correct behavior.

推荐答案

原来这是ASP.NET表单验证。至于根据这个,该包的名字不应该是一个存在的目录。和好,窗体身份验证拒绝访问说不准INT web.config中的目录。

Turns out it was ASP.NET form authentication. As according to this, the name of the bundle should not be an existing directory. And well, forms authentication denies access to those directories that are not allowed int the web.config.

我不知道包创建自己的目录,所以我基本上添加的位置标记的那些目录(即使它们不是物理的溶液)。

I did not know that the bundles create their own directory, so I basically added the location tag for those directories (even though they are not physically in the solution).

所以基本上...

有关以前所有的包的名字,我补充说:〜/包/然后创建在web.config以下位置标记:

For all of the previous bundles names, I added "~/bundles/" and then created the following location tag in the web.config:

<location path="bundles">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

这篇关于发布的WebForms应用时捆绑缩小不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆