Rai*_*lol 14 c# webforms bundling-and-minification
我正在尝试对一些.css和.js文件使用bundle minification.我的bundle配置如下:
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;
}
Run Code Online (Sandbox Code Playgroud)
当我将应用程序发布到服务器(godaddy共享虚拟主机)时,问题就出现了,我确实得到了一个缩小的输出,但是我在这些输出上得到403错误.
如果我订
BundleTable.EnableOptimizations = false;
Run Code Online (Sandbox Code Playgroud)
文件不会缩小,但页面具有正确的行为.
Rai*_*lol 16
原来它是ASP.NET表单身份验证.根据这一点,bundle的名称不应该是现有目录.好吧,表单身份验证拒绝访问web.config中不允许的那些目录.
我不知道bundle会创建自己的目录,所以我基本上为这些目录添加了位置标记(即使它们实际上不在解决方案中).
基本上......
对于所有以前的bundle名称,我添加了"〜/ bundles /",然后在web.config中创建了以下位置标记:
<location path="bundles">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)