C# 让jquery与MVC4协同工作

C# 让jquery与MVC4协同工作,c#,jquery,asp.net-mvc,razor,C#,Jquery,Asp.net Mvc,Razor,它没有发生。我尝试将_Layout.cshtml中的脚本正常链接到BundleCollection类具有IgnoreList属性,该属性包含不会呈现的文件名模式。默认情况下,它忽略具有minword的名称。您可以在注册表文件夹中清除此列表: public static void RegisterBundles(BundleCollection bundles) { bundles.IgnoreList.Clear(); bundles.Add(new ScriptBundle("

它没有发生。我尝试将_Layout.cshtml中的脚本正常链接到
BundleCollection
类具有
IgnoreList
属性,该属性包含不会呈现的文件名模式。默认情况下,它忽略具有
min
word的名称。您可以在
注册表文件夹中清除此列表:

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.IgnoreList.Clear();
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Views/Shared/Js/jquery-{version}.js",
        "~/Views/Shared/Js/jquery.color-{version}.js")
    );
}

让它工作起来:我所做的只是将脚本移动到另一个文件夹,
Content/Js
,并通过
将其链接到另一个文件夹中。当您直接引用jquery而不使用bundler(例如从CDN)时,它能工作吗?HTML输出是什么样子的?为什么不将它们放在脚本文件夹中?@MichaelCwienczek Nope,无论我是在_Layout.cshtml的标题中还是在我正在处理的页面的正文中引用它们。@ErikPhilips Oopes忽略了我最后的回复!我看到jquery脚本以正确的方式链接(源路径是
Views/Shared/Js/jquery-1.10.2.Js
),但有一个错误,在该位置找不到脚本。
public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Views/Shared/Js/jquery-{version}.js",
        "~/Views/Shared/Js/jquery.color-{version}.js")
    );
}
protected void Application_Start()
{
    // blah, etc, then:
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}
@Scripts.Render("~/bundles/jquery");
public static void RegisterBundles(BundleCollection bundles)
{
    bundles.IgnoreList.Clear();
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Views/Shared/Js/jquery-{version}.js",
        "~/Views/Shared/Js/jquery.color-{version}.js")
    );
}