Asp.net
Sys.WebForms.Res 未定義
- .NET 4.51 網路表單
- VS2013 更新 1
我從一個全新的 Web 項目開始,同時選擇了 WebForms 和 MVC 支持。在本地工作了幾天,沒有問題。但是,現在我在網路上部署它,我收到了錯誤:
TypeError: Sys.WebForms.Res 未定義
閱讀其他文章後,這似乎與 ScriptManager 等有關。所以下面是我的母版頁腳本管理器塊:
<asp:ScriptManager runat="server"> <Scripts> <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%> <%--Framework Scripts--%> <%--<asp:ScriptReference Name="jquery" />--%> <asp:ScriptReference Name="MsAjaxBundle" /> <asp:ScriptReference Name="bootstrap" /> <asp:ScriptReference Name="respond" /> <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" /> <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" /> <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" /> <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" /> <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" /> <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" /> <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" /> <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" /> <asp:ScriptReference Name="WebFormsBundle" /> <%--Site Scripts--%> </Scripts> </asp:ScriptManager> <div class="container body-content"> <asp:ContentPlaceHolder ID="cphMainWithoutUpdatePanel" runat="server"></asp:ContentPlaceHolder> <asp:UpdatePanel ID="updMain" runat="server"> <ContentTemplate> <asp:ContentPlaceHolder ID="cphMain" runat="server"></asp:ContentPlaceHolder> </ContentTemplate> </asp:UpdatePanel> </div>我在頭部聲明了 jQuery:
<script src="//code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>web.config 中對 AJAX 的唯一引用:
<appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="PreserveLoginUrl" value="true" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <authentication mode="None" /> <compilation targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> <pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Optimization" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> <add namespace="Microsoft.AspNet.Identity" /> </namespaces> </pages>除了更新面板,我沒有使用任何 MS AJAX AFAIK。所以沒有 AjaxControlToolkit。我在頁面中沒有自定義 JS 呼叫。
因此,由於這一切都在本地工作,它讓我相信遠端伺服器上的某些東西有所不同。但是,對於我的生活,我無法解決。有沒有人有任何建議?
真的需要得到這個生活所以任何幫助或建議,無論多麼牽強,都高興地收到。
我最終解決了這個問題。在我的情況下,出現此問題是因為在更新面板中發現的程式碼/控制項中存在一些其他低級異常。
一旦上述錯誤得到糾正,一切正常,Res 錯誤就消失了。現在,如果我有一個低級錯誤,例如 EF 問題或類似問題,錯誤就會回來。煩人,但至少我知道它是什麼以及如何處理它。
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />檢查 web.config 是否有上述程式碼塊。
來源:解決 IIS 7 下 ASP.NET AJAX RTM 中的“Sys is undefined”錯誤
看起來問題與瀏覽器沒有下載壓縮腳本有關,其他可能的原因在demystifying-sys-is-undefined部落格條目中討論。此頁面中的評論者提供了一種處理此 Sys 的方法,儘管它看起來像一個 hack。希望能幫助到你。