How do I add type=“text/javascript” to a script tag when using System.Web.Optimization

后端 未结 2 1264
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 22:17

I have the following

bundles.Add(new ScriptBundle(\"~/bundles/scripts/common\").Include(
                  \"~/Scripts/jquery.validationEngine.js\",
                


        
2条回答
  •  感动是毒
    2020-12-17 22:59

    I believe the answer marked is not correct for type="text/css", it is correct for JavaScript (maybe the question title is misleading?). For CSS files you should use

    @Styles.Render("~/bundles/styles/common")
    

    and not @Scripts.Render(...). The reason is that minification is done, and only @Styles.Render(...) knows about Cascading Stylesheet syntax, @Scripts.Render(...) is specialized for JavaScript minification.

提交回复
热议问题