Asp.net mvc asp.net mvc scripts.render服务于_lahout.cshtml而不是实际脚本

Asp.net mvc asp.net mvc scripts.render服务于_lahout.cshtml而不是实际脚本,asp.net-mvc,razor,Asp.net Mvc,Razor,在 我得到了一个javascript错误,它显示了jquery.js的内容,实际上里面是我的_layout.cshtml页面的内容 你知道为什么吗 编辑 @Scripts.Render("~/bundles/jquery") 下面是脚本文件夹的内容 引导数据采集器-Copier.js bootstrap-datepicker.js bootstrap-datepicker.min-Copier.js bootstrap-datepicker.min.js bootstrap.js boots

我得到了一个javascript错误,它显示了jquery.js的内容,实际上里面是我的_layout.cshtml页面的内容

你知道为什么吗

编辑

@Scripts.Render("~/bundles/jquery")
下面是脚本文件夹的内容

  • 引导数据采集器-Copier.js
  • bootstrap-datepicker.js
  • bootstrap-datepicker.min-Copier.js
  • bootstrap-datepicker.min.js
  • bootstrap.js
  • bootstrap.min.js
  • gridmvc.js
  • gridmvc.lang.ru.js
  • gridmvc.min.js
  • home.js
  • homeAbout.js
  • homeDialog.js
  • jquery-2.1.3.intellisense.js
  • jquery-2.1.3.js
  • jquery-2.1.3.min.js
  • jquery-2.1.3.min.map
  • jquery-ui-1.11.3.js
  • jquery-ui-1.11.3.min.js
  • jquery.unobtrusive-ajax.js
  • jquery.unobtrusive-ajax.min.js
  • jquery.validate-vsdoc.js
  • jquery.validate.js
  • jquery.validate.min.js
  • jquery.validate.unobtrusive.bootstrap.js
  • jquery.validate.unobtrusive.bootstrap.min.js
  • jquery.validate.unobtrusive.bootstrap.min.js.map
  • jquery.validate.unobtrusive.js
  • jquery.validate.unobtrusive.min.js
  • 现代化-2.6.2.js
  • respond.js
  • respond.min.js
  • _references.js

    • 所以问题是,我试图在未经身份验证的情况下从文件夹中获取脚本。这将导致从重定向到包含_layout.cshtml的页面

      为了解决这个问题,我使用以下命令编辑了web.config:

      public class BundleConfig
      {
          public static void RegisterBundles(BundleCollection bundles)
          {
              bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
              bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include("~/Scripts/jquery-ui-1.11.3.js"));
              bundles.Add(new ScriptBundle("~/bundles/jquery-validate").Include(
                      "~/Scripts/jquery.validate.js", 
                      "~/Scripts/jquery.validate.unobtrusive.js", 
                      "~/Scripts/jquery.unobtrusive-ajax.min.js"));
              bundles.Add(new ScriptBundle("~/bundles/modernizr").Include("~/Scripts/modernizr-*"));
              bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap.js", "~/Scripts/respond.js"));
      
              bundles.Add(new StyleBundle("~/Content/css").Include(
                    "~/Content/bootstrap_spacelab.css", "~/Content/Site.css", "~/Content/themes/base/all.css"));
          }
      }
      
      
      

      这样,我就可以访问SCIRPT而无需经过身份验证

      确保bundle.config中的代码正确。您在bundle.config中提到的路径是正确的,文件位于这些路径上。你能分享你的bundle.config吗?
        <location path="Scripts">
            <system.web>
              <authorization>
                <allow users="*"/>
              </authorization>
            </system.web>
          </location>
          <location path="Content">
            <system.web>
              <authorization>
                <allow users="*"/>
              </authorization>
            </system.web>
          </location>