我想包括目录中的所有文件,如下所示:

bundles.Add(new StyleBundle("~/Content/simpliq_css").Include(
    "~/Content/simpliq/*.css"
));

但我犯了Index was outside the bounds of the array个错误

红线是:

@Styles.Render("~/Content/simpliq_css")

[IndexOutOfRangeException: Index was outside the bounds of the array.]
   System.String.get_Chars(Int32 index) +0
   Microsoft.Ajax.Utilities.CssParser.Append(Object obj, TokenType tokenType) +402
   Microsoft.Ajax.Utilities.CssParser.AppendCurrent() +74
   Microsoft.Ajax.Utilities.CssParser.ParseElementName() +321
   Microsoft.Ajax.Utilities.CssParser.ParseSimpleSelector() +54
   Microsoft.Ajax.Utilities.CssParser.ParseSelector() +555
   Microsoft.Ajax.Utilities.CssParser.ParseRule() +165
   Microsoft.Ajax.Utilities.CssParser.ParseStylesheet() +186
   Microsoft.Ajax.Utilities.CssParser.Parse(String source) +946
   Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(String source, CssSettings settings, CodeSettings scriptSettings) +439
   Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(String source, CssSettings settings) +73
   System.Web.Optimization.CssMinify.Process(BundleContext context, BundleResponse response) +302
   System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable`1 bundleFiles) +207
   System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context) +355
   System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) +104
   System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) +254
   System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable`1 refs) +435
   System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) +1030
   System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +75
   System.Web.Optimization.Styles.RenderFormat(String tagFormat, String[] paths) +293
   System.Web.Optimization.Styles.Render(String[] paths) +51
   ASP._Page_Areas_Admin_Views_Shared__Layout_cshtml.Execute() in f:\MyProjects\Fables\Fables\Fables.Web\Areas\Admin\Views\Shared\_Layout.cshtml:8
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +120
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +145
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +41
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +335
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +53
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
   System.Web.WebPages.WebPageBase.PopContext() +347
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +154
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
   System.Web.Mvc.Async.<>c__DisplayClass28.<BeginInvokeAction>b__19() +321
   System.Web.Mvc.Async.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult) +185
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

推荐答案

Next软件包的版本中存在问题:

在此处输入图像描述

你必须更新它,问题就会解决.

Asp.net相关问答推荐

在Docker Windows中,ASP.NET核心容器在自定义端口8080上运行,但ASP.NET容器在固定端口80上运行

如何在 asp.net 服务器中使用字体

在 AppConfig.json 中存储对象的最佳方式

系统日期时间?与 System.DateTime

格式化 DataBinder.Eval 数据

asp.net、url 重写模块和 web.config

如果站点在 localhost 或 127.0.0.1 上运行,如何判断 ASP.NET MVC 视图

如何在集线器类之外获取 SignalR 用户连接 ID?

HTTP 错误 503.该服务在简单的 ASP.NET 4.0 网站下不可用

在不知道键名的情况下访问 JSON 对象的元素

MVC 3视图中的当前上下文中不存在名称'HTML'

ASP.NET 中的多选下拉列表

如何从url中删除returnurl?

模型是否包含字段而不将其添加到数据库中?

避免将重复元素添加到列表 C#

如何获取部署在 Azure 网站上的 ASP.NET 5 应用程序的错误详细信息?

URL 路由、图像处理程序和潜在危险的 Request.Path 值

在 ASP.NET 中获取服务器的 IP 地址?

Facebook 连接和 ASP.NET

如何使 URL 重写与 web.Release.config 转换一起工作?