【发布时间】:2013-05-02 02:12:44
【问题描述】:
每个控制器都有一个文件夹(同名控制器),每个动作都有一个脚本文件。
为每个文件创建一个遵循模式的包:"~/Scripts/Controllers/{controller-name}/{filename-without-extension}"
bundles.IncludePerFile(new DirectoryInfo(server.MapPath("~/Scripts/Controllers")), "~/Scripts/Controllers/{0}/{1}",
(dir,file) => string.Format("~/Scripts/Controllers/{0}/{1}", dir, Path.GetFileNameWithoutExtension(file)), "*.js");
IncludePerFile 是我为执行此任务而创建的扩展方法
那么应该存在一个用于:~/Scripts/Controllers/processos/pasta 的包!
并确认这一点:
到目前为止都是正确的!捆绑包存在!
正在运行的应用程序
当我运行应用程序时,出现以下错误:
错误且低效的错误修复:
如果我改变这个:
@Scripts.Render("~/Scripts/Controllers/processos/pasta")
到这里:
@Scripts.Render("~/Scripts/Controllers/processos/pasta.js")
不会产生错误。但是文件没有被缩小,因为实际上有一个包。 (我已经进入发布模式并发布了应用程序!)
完全错误
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
Line 3: @section js {
Line 4: @*@Scripts.Render("~/Scripts/Controllers/processos/Pasta.js", "~/Scripts/Controllers/processos/display.js")*@
Line 5: @Scripts.Render("~/Scripts/Controllers/processos/pasta")
Line 6: @Scripts.Render("~/Scripts/Controllers/processos/display.js")
Line 7:
Source File: w:\Clients\creditoimobiliariobb\sistema\src\CreditoImobiliarioBB\CreditoImobiliarioBB.Web\Views\processos\display.cshtml Line: 5
Stack Trace:
[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.SkipToClose() +744
Microsoft.Ajax.Utilities.CssParser.SkipToEndOfStatement() +232
Microsoft.Ajax.Utilities.CssParser.ParseRule() +574
Microsoft.Ajax.Utilities.CssParser.ParseStylesheet() +1235
Microsoft.Ajax.Utilities.CssParser.Parse(String source) +897
Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(String source, CssSettings settings) +419
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) +1029
System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +75
System.Web.Optimization.Scripts.RenderFormat(String tagFormat, String[] paths) +292
System.Web.Optimization.Scripts.Render(String[] paths) +51
【问题讨论】:
-
你找到答案了吗?
-
我收到此错误。恶意包包括标准 MVC5 Bootstrap js 资产。
-
答案太简单了 :) 你必须更新你的包(Microsoft Web Optimization & WebGrease)fsou1.com/…
标签: asp.net-mvc-4 asp.net-optimization