几天来,我一直在尝试发布一个小型 Intranet WebForms 应用程序 (.NET 4.0),并且一直在跟踪已在此处结束的脚本错误的痕迹。最初,脚本管理器抱怨在我的 Site.Master 文件中找不到引用的“MsAjaxBundle”。一些搜索把我带到了这个页面。我按照这些指示安装了 AjaxControlToolkit 并相应地修改了我的 Web.config。
该网站现在抛出此错误:
程序集“AjaxControlToolkit, Version=4.1.60919.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e”不包含名为“WebFormsBundle”的 Web 资源。
如果我注释掉 WebFormsBundle 引用,该站点至少会呈现一半,但不会将数据从 SQL 拉到我的 jqGrid 中。
我已经尝试了 2012 年 9 月版本的工具包以及最新版本,但每个版本都会引发此错误。这让我很生气,因为当然,该网站在本地构建和运行时运行良好。
堆栈跟踪以供进一步参考:
[InvalidOperationException: The assembly 'AjaxControlToolkit, Version=4.1.60919.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' does not contain a Web resource that has the name 'WebFormsBundle'. Make sure that the resource name is spelled correctly. Make sure that the application references the correct version of an ASP.NET AJAX Framework assembly.]
System.Web.UI.WebResourceUtil.VerifyAssemblyContainsReleaseWebResource(Assembly assembly, String releaseResourceName, Assembly currentAjaxAssembly) +305
System.Web.UI.ScriptReference.ShouldUseDebugScript(String releaseName, Assembly assembly, Boolean isDebuggingEnabled, Assembly currentAjaxAssembly) +91
System.Web.UI.ScriptReference.DetermineResourceNameAndAssembly(ScriptManager scriptManager, Boolean isDebuggingEnabled, String& resourceName, Assembly& assembly) +101
System.Web.UI.ScriptReference.GetUrlFromName(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +105
System.Web.UI.ScriptReference.GetUrlInternal(ScriptManager scriptManager, Boolean zip) +601
System.Web.UI.ScriptReference.GetUrl(ScriptManager scriptManager, Boolean zip) +206
System.Web.UI.ScriptManager.RegisterUniqueScripts(List`1 uniqueScripts) +204
System.Web.UI.ScriptManager.RegisterScripts() +449
System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +125
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +113
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8167
工具包声明:
<ajaxToolkit:ToolkitScriptManager runat="server">
<Scripts>
<%--Framework Scripts--%>
<%--<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Name="WebForms.js" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />--%>
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</ajaxToolkit:ToolkitScriptManager>
删除具有相对路径的脚本的 Name 属性解决了绊倒它们的问题,因此这些行被注释掉了。