Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jQuery在asp.net MVC中未缩小_C#_Jquery_Asp.net_Asp.net Mvc 3 - Fatal编程技术网

C# jQuery在asp.net MVC中未缩小

C# jQuery在asp.net MVC中未缩小,c#,jquery,asp.net,asp.net-mvc-3,C#,Jquery,Asp.net,Asp.net Mvc 3,我正在使用ASP.NETMVC 由于某些原因,我的JS文件没有缩小。我的CSS正在缩小 我的CSS缩小为:但我的所有JS文件都在源代码中单独列出 我正在以发布模式编译和发布 有人能告诉我如何解决这个问题吗 谢谢, 标记 BootstrapBundleConfig.cs using System.Web; using System.Web.Mvc; using System.Web.Optimization; namespace BootstrapSupport { public class B

我正在使用ASP.NETMVC

由于某些原因,我的JS文件没有缩小。我的CSS正在缩小

我的CSS缩小为:但我的所有JS文件都在源代码中单独列出

我正在以发布模式编译和发布

有人能告诉我如何解决这个问题吗

谢谢,

标记

BootstrapBundleConfig.cs

using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;

namespace BootstrapSupport
{
public class BootstrapBundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/js").Include(
            "~/Scripts/jquery-{version}.js",
            "~/Scripts/jquery-migrate-{version}.js",
            "~/Scripts/bootstrap.js",
            "~/Scripts/jquery.validate.js",
            "~/scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.validate.unobtrusive-custom-for-bootstrap.js",
            "~/Scripts/knockout-2.2.0.js",
            "~/Scripts/bootstrap-combobox.js",
             "~/Scripts/select2.js"
            ));

        bundles.Add(new ScriptBundle("~/mt").Include(
           "~/Scripts/bootstrap-datepicker.js",
                            "~/Scripts/mtDateEdit.js",
                            "~/Scripts/jquery-te-1.4.0.js"
                            //"~/Scripts/tinymce/tinymce.js"
                            ));

        bundles.Add(new StyleBundle("~/content/css").Include(
            "~/Content/bootstrap.css",
            "~/Content/body.css",
            "~/Content/bootstrap-responsive.css",
            "~/Content/bootstrap-mvc-validation.css",
            "~/Content/bootstrap-combobox.css",
             "~/Content/select2.css",
            "~/Content/datepicker.css",
            "~/Content/jquery-te-1.4.0.css"
            ));
    }
}
}
Global.asax.cs

   public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        AuthConfig.RegisterAuth();

        BootstrapSupport.BootstrapBundleConfig.RegisterBundles(System.Web.Optimization.BundleTable.Bundles);

        BootstrapMvcSample.ExampleLayoutsRouteConfig.RegisterRoutes(RouteTable.Routes);
        RegisterViewMapper();
    }
_Bootstrap.Layout.Basic.cshtml-文件底部:

 <div class="container">
     @Scripts.Render("~/js")
     @Scripts.Render("~/mt")
     @RenderSection("Scripts", required: false)

     @Html.Partial("_alerts")
     @Html.Partial("_validationSummary")
     @RenderBody()   

 </div>

您可以强制它仅用于发布模式,只需在应用程序_Start中添加以下代码即可

 #if RELEASE            
        BundleTable.EnableOptimizations = true;            
 #endif

您可以强制它仅用于发布模式,只需在应用程序_Start中添加以下代码即可

 #if RELEASE            
        BundleTable.EnableOptimizations = true;            
 #endif
尝试使用BundleTable.EnableOptimizations=true强制执行

如您所述,如果存在缩小/绑定错误,请从绑定中逐个删除*.js文件,直到找到有问题的文件为止。一旦找到它,请尝试将换行符添加到此文件的顶部和结尾。

尝试使用BundleTable强制执行。EnableOptimizations=true


如您所述,如果存在缩小/绑定错误,请从绑定中逐个删除*.js文件,直到找到有问题的文件为止。一旦找到它,请尝试在该文件的顶部和结尾添加换行符。

您处于调试模式还是发布模式?Hi-发布模式。我的CSS缩小为:-但我的所有JS文件都在源代码中单独列出。谢谢,mark您是否尝试使用BundleTable强制它。EnableOptimizations=true;嗨@lalibi-谢谢你的工作。看起来有缩小错误,这也许就是它不能自动工作的原因。请发布一个答案,我会这样标记。谢谢,你是在调试模式还是发布模式?Hi-release模式。我的CSS缩小为:-但我的所有JS文件都在源代码中单独列出。谢谢,mark您是否尝试使用BundleTable强制它。EnableOptimizations=true;嗨@lalibi-谢谢你的工作。看起来有缩小错误,这也许就是它不能自动工作的原因。请发布一个答案,我会这样标记。谢谢你,马克