ASP.NET Ajax not running with IIS 7 - asp.net

I have a small web application with ASP.NET AJAX running well under the Cassini ASP.NET from http://www.ultidev.com/. But when I tried to host it under IIS7, the AJAX is not working. The UpdatePanel, the Calendar extension, the client side validation from the Validation Control are not working at all. I think it must be a problem of IIS 7.
Here's a section of the web.config file:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<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>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.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=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/></handlers>
</system.webServer>
Can anyone tell me what the problme is with IIS 7? How should I configure it to work with ASP.NET AJAX? Thank you.

Add the following line in the Handlers section in the web.config file:
<add name="Ajax" verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>

I just removed Web Server role and added Web Server role again. It's working now. I think maybe some component that IIS 7 was set up in the first place.

Delete the next code line if you added AJAX from NUGET and after you add ajaxcontroltoolkit.dll from
here: http://ajaxcontroltoolkit.codeplex.com/releases/view/109918
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
PD: AJAX CONTROL TOOL KIT 4.5 NOT WORKS WITH FRAMEWORK 4.5. AND AJAX FROM NUGET HAS PROBLEM

Related

ASP.NET httphandlers webconfig file Integrated mode

I have a web.config file which contains
<system.web>
<httpHandlers>
<add verb="*" path="*.pdf" type="InfomationDev.Info.write.writeModule, InformationDev.Info.write"/>
</httpHandlers>
</system.Web>
**After running appcmd migrate command IIS6 to IIS7 we got new section**
<system.webServer>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="*.pdf" verb="*" path="*.pdf" type="InfomationDev.Info.write.writeModule, InformationDev.Info.write"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.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=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
The problem is:
if I removed completely hhtpHandlers section it is working in Integrated mode.
if I removed completely system.webserver section it is working in Classic mode.
If I wanted to work on both modes(sometimes classic & Integrated) so I added both sections as shown above throwing exception 500 Internal server error.I want to work
in both Integrated & classic modes without using
validateIntegratedModeConfiguration="false".
How can we do that?

UpdatePanel does not work after publish

I have website (C#, ASP.NET, .NET 4.0) and using ASP.NET Ajax (Update Panel) and jQuery Ajax.
On client side, everything is ok and there is no any error...
After publish the website on the host, jQuery ajax work fine but update panel does not work and make postback and page refresh!
the .NET setting of host is .NET 4.0 too.
i dont know where is the problem and why?
The error on client was:
SCRIPT5022: ASP.NET Ajax client-side framework failed to load.
SCRIPT5009: 'Sys' is undefined
After many time to mining the websites, and more solutions, i solve the problem:
the solution for .NET 4.0 is:
Set EnableCdn property of script manager to true :)
Like this:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true">
Next Solution and Better Solution is:
add this handler to your web.config
<system.webServer>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
I suggest you to check whether all the ajax libraries are copied to the publish folder

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).

ScriptResource.axd and .Net 4

We have just converted our website to run on .NET 4 and upgraded our server (Web Server 2008 SP2 IIS7.0) to run the .NET 4 framework. Our site now displays the following problem on 50% of all computers that try to access it whereas the other 50% work perfectly. All worked fine under .NET 3.5
Sys.WebForms.PageRequestManagerServerErrorException: The requested name is valid, but no data of the requested type was found. ScriptResource.axd Code:0 Line:5 Char:89043
Our web.config has the following defined:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<directoryBrowse enabled="true" />
<modules>
<remove name="ScriptModule"/>
<add name="ASPxHttpHandlerModule" type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
The site runs with an Application Pool defined as:
.NET Framework Version: v4.0
Managed Pipeline Mode: Integrated
We switched the site to download the Ajax scripts from the MS Content delivery Network (ScriptManager EnableCdn="True") and still had the same problem except this time we get the problem occurring in:
MicrosoftAkaxWebForms.debug.js Line: 868 Char:13
Have removed all our own scripts and the Ajax Control Toolkit to no avail. What is mystifying is that it works ok on 50% of machines and not on the other 50%. There is no commonality between the works/not works. Different o/s different browser mixes. e.g. works fine on one machine Win 7 / IE8 fails on one machine same o/s and browser...works fine on one machine XP Firefox3 fails on another same config.
Any help greatly appreciated (getting desperate!!)
Lastest update:
We reverted the site to .Net 3.5 without changing any code on the site and all works perfectly. Guess we will stick at 3.5 for the foreseeable future!!
Dont give up just yet, had a few headaches when I upgraded our site to 4.0 but nothing a few hours of hair pulling didnt resolve!
Looking at your web.config...
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
These modules are still referencing the old 3.5 libraries. Update your references to point at the new 4.0 versions of these libaries.
Please also look into the changes which have been made in 4.0 to minimise web.config settings. One way to get started would be to create a new 4.0 website work out what you need to add to the web.config to get up and running.
I'm using the AJAX control toolkit on our 4.0 sites and I dont have any of the handlers you have registered and I dont belive you need any of them (apart from maybe
the DevExpress one).
Ta
Steve

Win7/IIS7 - why does a new Handler Mapping diasappear?

I add a handler mapping to IIS7 (on Win7). It runs just fine until I publish a new build to http://localhost. Once I publish a new build, all the mappings I added are magically gone!!
[EDIT]
I am also losing all of my virtual directories during a publish.
[/EDIT]
Any tips/tricks for this?
The handlers are now stored in the app's web.config instead of in the metabase. Because of that, if you copy out an old copy of the web.config, your changes are lost.
Look at the system.webServer element of your web.config. One of mine looks like:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.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=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.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=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>

Resources