2015-06-19 49 views
0

實時應用程序已部署一段時間並正常工作。應用程序池是v2.0 Classic。它位於Windows Server 2008 R2上。ASP.NET AJAX無法在.NET 3.5的本地主機上工作

我的本地環境是Windows 8.1。我在IIS Express中進行調試。瀏覽器開發人員工具中出現以下錯誤:

  • 未捕獲的錯誤:ASP.NET Ajax客戶端框架未能加載。
  • 未捕獲的ReferenceError:SYS沒有定義

所有的ScriptResource.axd的GET請求導致404錯誤。任何關於修復.NET Ajax的想法?

順便說一句,我已經完成了我以前見過的關於如何解決這個問題的所有建議,特別是處理程序。我有以下web.config。

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
     <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/> 
      <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
      <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
      <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
     </sectionGroup> 
     </sectionGroup> 
    </sectionGroup> 
    </configSections> 
    <appSettings> 
    <!-- snipped --> 
    </appSettings> 
    <connectionStrings> 
    <!-- snipped --> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" strict="false" explicit="true"> 
     <assemblies> 
     <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> 
     <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     <add assembly="System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> 
     <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     </assemblies> 
    </compilation> 
    <pages> 
     <namespaces> 
     <clear/> 
     <add namespace="System"/> 
     <add namespace="System.Collections"/> 
     <add namespace="System.Collections.Specialized"/> 
     <add namespace="System.Configuration"/> 
     <add namespace="System.Text"/> 
     <add namespace="System.Text.RegularExpressions"/> 
     <add namespace="System.Web"/> 
     <add namespace="System.Web.Caching"/> 
     <add namespace="System.Web.SessionState"/> 
     <add namespace="System.Web.Security"/> 
     <add namespace="System.Web.Profile"/> 
     <add namespace="System.Web.UI"/> 
     <add namespace="System.Web.UI.WebControls"/> 
     <add namespace="System.Web.UI.WebControls.WebParts"/> 
     <add namespace="System.Web.UI.HtmlControls"/> 
     </namespaces> 
     <controls> 
     <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/> 
     <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </controls> 
    </pages> 
    <httpHandlers> 
     <remove verb="*" path="*.asmx"/> 
     <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false"/> 
    </httpHandlers> 
    <httpModules> 
     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
    </httpModules> 
    <authentication mode="Forms"> 
     <forms loginUrl="login.aspx" timeout="120" slidingExpiration="true"/> 
    </authentication> 
    <authorization> 
     <allow roles="(snipped)"/> 
     <deny roles="(snipped)"/> 
     <deny users="?,*"/> 
    </authorization> 
    <roleManager enabled="true" defaultProvider="SimpleRoleProvider"> 
     <providers> 
     <clear/> 
     <add name="SimpleRoleProvider" type="MyProject.SimpleRoleProvider" applicationName="MyProject"/> 
     </providers> 
    </roleManager> 
    <customErrors mode="RemoteOnly" defaultRedirect="error"> 
     <!--<error statusCode="403" redirect="NoAccess.htm" /> 
     <error statusCode="404" redirect="FileNotFound.htm" />--> 
     <error statusCode="500" redirect="error/500.html"/> 
    </customErrors> 
    <sessionState mode="InProc" cookieless="false" timeout="240"/> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <handlers> 
     <remove name="WebServiceHandlerFactory-Integrated" /> 
     <add name="Telerik.Web.UI.WebResource.axd_*" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" preCondition="integratedMode,runtimeVersionv2.0" /> 
     <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
     <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
     <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" /> 
    </handlers> 
    <rewrite> 
     <rules> 
     <rule name="API Rule" stopProcessing="true"> 
     <match url="api/(.*)" /> 
     <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> 
      <add input="{REQUEST_URI}" pattern="/api/PublicService\.svc.*" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="api/PublicService.svc/{R:1}" appendQueryString="true" /> 
     </rule> 
     <rule name="Main Rule" stopProcessing="true"> 
      <match url=".*"/> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> 
      </conditions> 
      <action type="Rewrite" url="index.php/{R:0}"/> 
     </rule> 
     </rules> 
    </rewrite> 
    <modules> 
     <remove name="ScriptModule"/> 
     <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
    </modules> 
    </system.webServer> 
    <location path="ScriptResource.axd"> 
    <system.web> 
     <authorization> 
     <allow users="*"/> 
     </authorization> 
    </system.web> 
    </location> 
    <!-- other locations snipped --> 
    <system.serviceModel> 
    <extensions> 
     <behaviorExtensions> 
     <add name="MyWebHttpBehaviorExtension" type="MyProject.CustomBehaviorExtensionElement, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
     <add name="MyFaultHiderBehaviorExtension" type="MyProject.FaultHiderBehaviorExtensionElement, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
     </behaviorExtensions> 
    </extensions> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="MyProject.AspNetAjaxBehavior"> 
      <enableWebScript/> 
      <MyWebHttpBehaviorExtension/> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="MyProject.AspNetAjaxBehavior"> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> 
    <services> 
     <service name="MyProject.Api.PublicService"> 
     <endpoint address="" behaviorConfiguration="MyProject.AspNetAjaxBehavior" bindingConfiguration="WebServicesBinding" binding="webHttpBinding" contract="MyProject.Api.PublicService"/> 
     </service> 
    </services> 
    <bindings> 
     <webHttpBinding> 
     <binding name="WebServicesBinding"> 
      <security mode="None"/> 
     </binding> 
     <binding name="WebServicesBindingHttps"> 
      <security mode="Transport"/> 
     </binding> 
     </webHttpBinding> 
     <basicHttpBinding> 
     <binding name="GatewaySoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
      <message clientCredentialType="UserName" algorithmSuite="Default"/> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    </system.serviceModel> 
    <system.codedom> 
     <compilers> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> 
      <providerOption name="CompilerVersion" value="v3.5"/> 
      <providerOption name="OptionInfer" value="true"/> 
      <providerOption name="WarnAsError" value="false"/> 
     </compiler> 
    </compilers> 
    </system.codedom> 
    <runtime> 
    <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/> 
     <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/> 
     <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

我已經仔細檢查了IIS Express的applicationhost.config中的AXD處理程序。看來我有.NET 2.0 AXD處理程序。 (但我在解釋這些小知識。)

<handlers accessPolicy="Read, Script"> 
     <!-- non-AXD handlers snipped --> 
     <add name="AXD-ISAPI-4.0_64bit" path="*.axd" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
     <add name="AXD-ISAPI-4.0_32bit" path="*.axd" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
     <add name="TraceHandler-Integrated-4.0" path="trace.axd" verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TraceHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
     <add name="WebAdminHandler-Integrated-4.0" path="WebAdmin.axd" verb="GET,DEBUG" type="System.Web.Handlers.WebAdminHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
     <add name="AssemblyResourceLoader-Integrated-4.0" path="WebResource.axd" verb="GET,DEBUG" type="System.Web.Handlers.AssemblyResourceLoader" preCondition="integratedMode,runtimeVersionv4.0" /> 
     <add name="ScriptHandlerFactoryAppServices-Integrated-4.0" path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode,runtimeVersionv4.0" /> 
     <add name="ScriptResourceIntegrated-4.0" path="*ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode,runtimeVersionv4.0" /> 
     <add name="TraceHandler-Integrated" path="trace.axd" verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TraceHandler" preCondition="integratedMode,runtimeVersionv2.0" /> 
     <add name="WebAdminHandler-Integrated" path="WebAdmin.axd" verb="GET,DEBUG" type="System.Web.Handlers.WebAdminHandler" preCondition="integratedMode,runtimeVersionv2.0" /> 
     <add name="AssemblyResourceLoader-Integrated" path="WebResource.axd" verb="GET,DEBUG" type="System.Web.Handlers.AssemblyResourceLoader" preCondition="integratedMode,runtimeVersionv2.0" /> 
     <add name="AXD-ISAPI-2.0" path="*.axd" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" /> 
     <add name="AXD-ISAPI-2.0-64" path="*.axd" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" responseBufferLimit="0" /> 
    </handlers> 
+0

檢查在IIS中的處理程序映射中是否有* .axd。在我的機器上,它被映射到%windir%\ Microsoft.NET \ Framework \ v4.0.30319 \ aspnet_isapi.dll – Stilgar

+0

請參閱上面的其他信息。 – David

回答

0

固定。問題不在於我的web.config。事實上,我找不到任何我的文件或代碼的問題。最終,我不得不重新創建項目並複製我的文件。具體來說,按順序:

  1. 創建新的空白ASP.NET項目。 (Visual Studio默認爲4.5。)
  2. 將目標框架更改爲版本3.5。
  3. 複製當前項目中的代碼文件。
  4. 在新項目的項目屬性中,確保新項目的程序集名稱和根名稱空間與現有項目的名稱空間匹配。
  5. 在新項目中添加必要的參考。
  6. 在調試模式下運行新項目,對其進行測試,確認所有工作正常。
  7. 所有內容複製回來,覆蓋舊的項目,要注意以下幾點:
    1. 沒有必要覆蓋舊的解決方案(在我的情況,反正)。
    2. 一定要覆蓋舊的VS proj文件和bin文件夾。
    3. 我使用Git進行源碼控制,所以它會自動選取任何新/不同的文件,並忽略其他文件。
  8. 在我的情況下,有兩種可能性(我能想到)是問題的根源。我不知道哪一個是真正原因:
    1. 我失蹤/My Project/MyExtensions/MyWebExtension.vb
    2. vsproj文件中的某些東西。
0

由於網站被配置爲運行在.NET 2.0(或可能3.5),你需要在你的bin安裝AJAX控件工具包的DLL,因爲它們是可能安裝到生產服務器上的GAC,這就是爲什麼它在那裏工作。爲了能夠加載2.0 DLL,您需要將DLL安裝到計算機上的GAC中,或將它們包含在bin目錄中。 This answer應該有幫助。

+0

它已經在項目的bin文件夾中,並且參考指向它。儘管如此,它是工具包版本1.0.20229,我猜是ASP.NET AJAX 1.0和.NET Framework 2.0。我下載了新的工具包(版本3.5.20229,用於.NET Framework 3.5),替換了該DLL文件,並重新創建了該引用。 (將原始引用保留在粘貼新​​文件後,甚至可以構建項目)。新DLL或引用的行爲沒有變化。我得到同樣的錯誤。 – David

+0

[DId你配置IIS Express使用經典](http://stackoverflow.com/questions/5914744/force-iis-express-to-classic-pipeline-mode)?您也可能[需要在IIS Express中將站點的應用程序池配置爲2.0](http://stackoverflow.com/questions/4890394/iis-express-and-asp-net-2-0)。 –

+0

我做到了。它配置爲2.0。應用程序池名稱爲Clr2ClassicAppPool,其中'managedRuntimeVersion =「v2.0」managedPipelineMode =「Classic」'。 – David

相關問題