开发者

Error: 'Sys' is undefined

When I moved my website over to another server I've noticed now that ajax doesn't appear to be working.

When I remote desktop to the server and go to the url on the server i.e. http://myserver/mywebsite ... everything works ok.

When I open up the website in visual studio on the server it works as no problem as well.

It's only when I connect remotely that the 'javascript' error occurs.

To my web.config I've added:

<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" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" 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>

I've tried

<compilation debug="false"/>

and tried emptying web history and still no luck.

Any ideas?


Try this: http://blogs.telerik.com/blogs/posts/10-03-16/common_reasons_for_the_lsquo_sys_is_undefined_rsquo_error_in_asp_net_ajax_applications.aspx


The other conputer has another IIS Version (or AppPool integrated mode) installed. AJAX needs to be configured in the web.config file as you write above, but in IIS 7 it's in System.WebServer. I could give you a working sample for the two configured in the same file if i was at home and not in the train to home ;-) Anyway, you can get a correct Web.config file if you create a new web application with visual studio 2010.

Edit:

Copy this to the bottom of your web.config file:

 <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <!--
      <add name="WebServiceAuthenticationModule" preCondition="integratedMode" type="WebServiceAuthenticationModule.WebServiceAuthenticationModule, WebServiceAuthenticationModule" />
      -->
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <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>
  </system.webServer>

The only other reason for sys not defined is if you have no scriptmanager on the page where you use AJAX.

Sys is the JavasScript class which provides all the static functions for .NET AJAX calls.

And make sure the assembly System.Web.Extensions.dll is present on the other computer (or set localcopy to true).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜