How to use ScriptModule on Framework 4 in web.config? - asp.net

I want to use ASP.NET with jquery ajax post, which requires adding the following to web.config:
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
When I add it to web.config of application using framework 4.0 the application doesn`t work and I get a 500 - Internal server error and when I remove the code above the application works perfectly.
Is there anything I`m missing (add a refference or something)?!!!

Related

Ajax Cascading Drop Down works under Visual Studio Virtual Host but get method error 500 on IIS 7.0

I have downloaded the sample AJAX toolKit website.
When opened in Visual Studio 2012 everything works fine.
When I publish to IIS 7.0 Cascading Drop Down example gives method error 500.
I can browse to CarsService.asmx and invoke the GetDropDownContents method and get xml data returned so the service is working fine.
Suggestions?
I don't care if I use AJAX toolkit or not. I just want to create some webforms that populate data from an API.
Used answer from this question to solve problem I added following Code to my web.config file
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<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" />
</handlers> </system.webServer>

AjaxToolkit Asp.net 3.5 Sys Not Defined

I am trying to use the AjaxToolkit for a Asp.net 3.5 project. I have an existing project that I added the ajax configuration using this link http://www.asp.net/ajax/documentation/live/ConfiguringASPNETAJAX.aspx but I am getting a javascript error of Sys not defined. I am wondering if it has something to do with the handlers that were set up. I am using IIS 6 on a windows 2003 server using a .net 3.5 project any one have any ideas?
HTTP Handlers:
<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" />
My full web.config
http://pastebin.com/8AFLA3KA
You are missing the web.config entry in system.webserver.
Without the system.webserver entry, it will work on the development server and iis 6-, but not on IIS 7+ in integrated mode.
Another option is to switch the IIS7 app-pool into classic mode.
The Visual Studio web application templates got updates with a service pack, but your project got created before that update :)
Just make sure you installed all updates, create a new ajax project, and compare the web.config file.

UrlRewritting + ASP.NET AJAX + IIS 7 on localhost + IIS 7 Remote

I am getting these issue in my website if i use UrlRewritting with ASP.NET AJAX
I was getting ScriptResource.axd 404 Error on Devserver I removed that by using Rewrite rule for that and add that following code in web.config's section
<httpHandlers>
<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>
that method fixed my problem... but
I configured on my local PC's IIS 7 It is creating same problem so found the solution for IIS 7. I removed above and and add new code in web.config's section
<handlers>
<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>
that code fixed my problem...... but
when I configure on remote IIS i am getting same problem........ any one can answer How can I solve that???
I got the solution actually problem is version of System.Web.Extensions I changed version Version=1.0.61025.0 to Version=3.5.0.0 and it is work now.....

asp chart errors

I have a strange situation using asp ajax chart controls. I have an application which is attempting to display a chart on an aspx page. Here are a couple of snippets from my web.config -
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\temp\;"/>
</appSettings>
...
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
...
<handlers>
<remove name="ChartImageHandler"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
When I run the application through the VS2010 IDE, I am getting the following error when trying to display the chart -
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Unknown server tag 'asp:Chart'.
However, if I deploy it to my server, it seems that the chart cannot be found (an outline where the image would be appears with the red X saying that the image cannot be found).
The difference is that I am running the IDE from windows xp 32bit machine, and the server I deploy to is a 64bit Server 2008 machine running IIS 7.
Does anyone have any idea why I might be having these problems?
Thanks for any thoughts.
In the web.config <controls> section add the following:
<add tagPrefix="asp"
namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Or you can register the controls on the page you are using them.

Sys is undefined

I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error "Sys is undefined".
It doesn't happen all the time, but it is reproducible. When it happens, the user has to shut down their browser and reopen the page.
This leads me to believe that it could be an IIS setting.
Another note. I looked at the page source both when I get the error, and when not. When the page throws errors the following code is missing:
<script src="/ScriptResource.axd?d=EAvfjPfYejDh0Z2Zq5zTR_TXqL0DgVcj_h1wz8cst6uXazNiprV1LnAGq3uL8N2vRbpXu46VsAMFGSgpfovx9_cO8tpy2so6Qm_0HXVGg_Y1&t=baeb8cc" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>
I fixed my problem by moving the <script type="text/javascript"></script> block containing the Sys.* calls lower down (to the last item before the close of the body's <asp:Content/> section) in the HTML on the page. I originally had my the script block in the HEAD <asp:Content/> section of my page. I was working inside a page that had a MasterPageFile. Hope this helps someone out.
When I experienced the errors
Sys is undefined
ASP.NET Ajax client-side framework failed to load
in IE when using ASP.NET Ajax controls in .NET 2.0, I needed to add the following to the web.config file within the <system.web> tags:
<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="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
Try setting your ScriptManager to this.
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
Dean L's answer, https://stackoverflow.com/a/1718513/292060 worked for me, since my call to Sys was also too early. Since I'm using jQuery, instead of moving it down, I put the script inside a document.ready call:
$(document).ready(function () {
Sys. calls here
});
This seems to be late enough that Sys is available.
I was using telerik and had exactly same problem.
adding this to web.config resolved my issue :)
<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
maybe it will help you too. it was Authentication problem.
Source
Try one of this solutions:
1. The browser fails to load the compressed script
This is usually the case if you get the error on IE6, but not on other browsers.
The Script Resource Handler – ScriptResource.axd compresses the scripts before returning them to the browser. In pre-RTM releases, the handler did it all the time for all browsers, and it wasn’t configurable. There is an issue in one of the components of IE6 that prevents it from loading compressed scripts correctly. See KB article here. In RTM builds, we’ve made two fixes for this. One, we don’t compress if IE6 is the browser client. Two, we’ve now made compression configurable. Here’s how you can toggle the web.config.
How do you fix it? First, make sure you are using the AJAX Extensions 1.0 RTM release. That alone should be enough. You can also try turning off compression by editing your web.config to have the following:
<system.web.extensions>
<scripting>
<scriptResourceHandler enableCompression="false" enableCaching="true" />
</scripting>
</system.web.extensions>
2. The required configuration for ScriptResourceHandler doesn’t exist for the web.config for your application
Make sure your web.config contains the entries from the default web.config file provided with the extensions install. (default location: C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025)
3. The virtual directory you are using for your web, isn’t correctly marked as an application (thus the configuration isn’t getting loaded) - This would happen for IIS webs.
Make sure that you are using a Web Application, and not just a Virtual Directory
4. ScriptResource.axd requests return 404
This usually points to a mis-configuration of ASP.NET as a whole. On a default installation of ASP.NET, any web request to a resource ending in .axd is passed from IIS to ASP.NET via an isapi mapping. Additionally the mapping is configured to not check if the file exists. If that mapping does not exist, or the check if file exists isn't disabled, then IIS will attempt to find the physical file ScriptResource.axd, won't find it, and return 404.
You can check to see if this is the problem by coipy/pasting the full url to ScriptResource.axd from here, and seeing what it returns
<script src="/MyWebApp/ScriptResource.axd?[snip - long query string]" type="text/javascript"></script>
How do you fix this? If ASP.NET isn't properly installed at all, you can run the "aspnet_regiis.exe" command line tool to fix it up. It's located in C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727. You can run "aspnet_regiis -i -enable", which does the full registration of ASP.NET with IIS and makes sure the ISAPI is enabled in IIS6. You can also run "aspnet_regiis -s w3svc/1/root/MyWebApp" to only fix up the registration for your web application.
5. Resolving the "Sys is undefined" error in ASP.NET AJAX RTM under IIS 7
Put this entry under <system.webServer/><handlers/>:
<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" />
and remove the one under <system.web/><httpHandlers/>.
References:
http://weblogs.asp.net/chrisri/demystifying-sys-is-undefined
http://geekswithblogs.net/lorint/archive/2007/03/28/110161.aspx
I hate adding to such a huge topic and so much later, but I've think I have a solution that works in VS2015 at the very least.
I was on a hunt to find a reason for the sys error, and the only solution that worked for me was to add EnableCdn="true" in a ScriptManager like this:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true" />
See the MSDN for more information.
Why do we need to do this?
When working on a asp.net web application, you have to enable CDN so that Microsoft can download the Sys. library.
There was probably a script in your page that was using the Sys function. Setting EnableCdn="true" would ensure that the Sys library is downloaded before it is used.
What's CDN?
It stands for "Content Delivery Network" and enabling it allows certain resources to download with simple references.
A quote from https://www.sitepoint.com/7-reasons-to-use-a-cdn/
Most CDNs are used to host static resources such as images, videos,
audio clips, CSS files and JavaScript. You’ll find common JavaScript
libraries, HTML5 shims, CSS resets, fonts and other assets available
on a variety of public and private CDN systems.
Both Google and Microsoft have CDNs. All you have to do is add a reference. Usually CDNs are added via a script resource:
<script src="https://ajax.aspnetcdn.com/ajax/4.5.1/1/MicrosoftAjax.js" type="text/javascript"></script>
Once you set EnableCdn="true" and Microsoft will add it's little CDN reference (like the one above) in the page which downloads the Sys library.
I hope that helps anybody that ran into the same issue.
You must add these lines in the web.config
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
Hope this helps.
In addition to ensuring you have the ScriptManager on your page you need to ensure that your web.config is appropriately configured.
When ASP.NET AJAX 1.0 was released (for .NET 2.0) there was a lot of custom web.config settings which added handlers, controls, etc.
You'll find the config info here: http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx
Make sure that any client scripts you have that interact with .NET AJAX have the following line at the end:
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
This tells the script manager that the whole script file has loaded and that it can begin to call client methods
I was having this same issue and after much wrangling I decided to try and isolate the problem and simply load the script manager in an empty page which still resulted in this same error. Having isolated the problem I discovered through a comparison of my site's web.config with a brand new (working) test site that changing <compilation debug="true"> to <compilation debug="false"> in the system.web section of my web.config fixes the problem.
I also had to remove the <xhtmlConformance mode="Legacy"/> entry from system.web to make the update panel work properly. Click here for a description of this issue.
I solved this problem by creating separate asp.net ajax solution and copy and paste all ajax configuration from web.config to working project.
here are the must configuration you should set in web.config
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</configSections>
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<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>
In case none of the above works for you, and you happen to be overriding OnPreRenderComplete, make sure you call base.OnPreRenderComplete. My therapist is going to be happy to see me back
I had the same problem after updating my AjaxControlToolkit.dll to the latest version 4.1.7.725 from 4.1.60623.0.
I've searched and came up to this page, but none of the answers help me.
After looking to the sample website of the Ajax Control Toolkit that is in the CodePlex zip file, I have realized that the <asp:ScriptManager> replaced by the new <ajaxtoolkit:ToolkitScriptManager>. I did so and there is no Sys.Extended is undefined any more.
In my case the problem was that I had putted the following code to keep the gridview tableheader after partial postback:
protected override void OnPreRenderComplete(EventArgs e)
{
if (grv.Rows.Count > 0)
{
grv.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
Removing this code stopped the issue.
Was having a similar issue, except that my page was consistently generating the Sys is undefined error.
For me the problem stems from the fact that I've just installed the AJAX 1.0 extension for .NET 2.0 but had already created my web project in Visual Studio.
When tried to create AJAX controls I kept encountering this error, I spotted Slace's and MadMax1138s posts here. And figured it was my web.config, I created a new project using the new "AJAX enabled web site" project type, and sure enough the web.config has a large number of customizations necessary to use the AJAX controls.
I just updated that web.config with the web.config updates I had already made myself and dropped it into my existing project and everything worked fine.
I have been seeing the exact same error today, but it was not a config or direct JavaScript issue.
An external .net project had been updated but the changes not picked up properly in the compilation of the web site. My presumption is that ASP.NET ajax was not able to construct the client representations of the .NET objects properly and so was failing to load correctly.
To resolve, I rebuilt the external project(s), and rebuilt my solution that was experiencing issues. The problem went away.
I found the error when using a combination of the Ajax Control Toolkit ToolkitScriptManager and URL Write 2.0.
In my <rewrite> <outboundRules> I had a precondition:
<preConditions>
<preCondition name="IsHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"/>
</preCondition>
</preConditions>
But apparently some of my outbound rules weren't set to use the precondition.
Once I had that preCondition set on all my outbound rules:
<rule preCondition="IsHTML" name="MyOutboundRule">
No more problem.
Make sure you don't have any Rewrite rules that change your url.
In my case the application thought it was only level deeper then the url reached.
Example: http://mysite.com/app/page.aspx was the real url.
But i cut off /app/ this worked fine for ASP.net and WCF, but clearly not for Ajax.
I had similar problems and to my surprise what I found that one of my developer had saved web.config in the same folder/solution as web123.config and by mistake both of these files were uploaded.
As soon as I deleted the web123.config file, this error disappeared and ajax framework was loading correctly. even though I have
<compilation debug="true">
In my case I also have following segment. My project is using framework 3.5
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
This is going to sound stupid but I had a similar problem with a site being developed in VS2010 and hosted in the VS Dev Server. The page in question had a scriptmanager to create the connection to a wcf service. I added an extra method to the service and this error started appearing.
What fixed it for me was changing from 'Auto-assign Port' to 'Specific port' with a different port number in the oroject Web settings.
I wish I knew why...
Development Environment:
Dev-Env: VS 2012
FX: 4.0/4.5
Implementations: Master(ScriptManager + UpdatePanel/Timer) + Content (UpdatePanel)
Patterns: PageRouting.
Disclaimer:
If all the web.config solutions do not work for you and you have implemented PageRouting (IIS 7+), then the code snippet below will solve your problems.
Background:
Dont mean to Highjack this question but had the same problem as everyone else and implemented 100% of the suggestions here, with minor modifications for .Net 4.0/4.5, and none of them worked for me.
In my situation i had implemented Page Routing which was ghosting my problem. Basically it would work for about 20, or so, debug runs and then BAM would error out with the Sys is undefined error.
After reviewing a couple other posts, that got to talking about the Clean-URL logic, i remembered that i had done PageRouting setup's.
Here is the resource i used to build my patterns: Page Routing
My one-liner code fixed my VS2012 Debugging problem:
rts.Ignore("{resource}.axd/{*pathInfo}") 'Ignores any Resource cache references, used heavily in AJAX interactions.
Even after adding the correct entry for web config still getting this error ? most common reason for this error is JavaScript that references the Sys namespace too early.
Then most obvious fix would be move the java script block below the ScriptManager control:
I don't think this point has been added and since I just spent some time hunting this down I hope it can help.
I am working with IIS 7 and using the ASP.NET v4 Framework.
In my case it was important that an entry be added to both the and section of the entry in the web.config file.
My web.config file has a lot of handlers and in my case it was easiest to add the ScriptResources entry to the top of the handlers section. Most importantly, it needs to be placed before any entry that will act as a wildcard and capture the request. Adding it after a wildcard entry will cause it to be ignored and the error will still appear.The module can be added to the top or bottom of the section.
Web.config Sample:
<system.webServer>
<handlers>
<clear />
<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" />
<!-- Make sure wildcard rules are below the ScriptResource tag -->
</handlers>
<modules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<!-- Other modules are added here -->
</modules>
</system.webServer>
I had same probleme but i fixed it by:
When putting a script file into a page, make sure it is
<script></script> and not <script />.
I have followed this:
http://forums.asp.net/t/1742435.aspx?An+element+with+id+form1+could+not+be+found+Script+error+on+page+load
Hope this will help
Add
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
Please check enter link description here
In my case, I've found a very hidden reason ... There was this page route with in Global.ascx.cs which doesn't appear in my tests in sub-folders but returns the question error all the time .. another day with strange issues.
routes.MapPageRoute("siteDefault", "{culture}/", "~/default.aspx", false, new RouteValueDictionary(new { culture = "(\\w{2})|(\\w{2}-\\w{2})" }));
I know this is an old thread but I found a somewhat unique solution. In my case I was getting the error because I am using both Webforms and MVC in the same ASP.NET web application. After mapping routes the issue showed up. I fixed it by adding the following code to ignore routes for both "{resource}.aspx/{*pathInfo}" and "{resource}.axd/{*pathInfo}"
private void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Test", action = "Index", id = UrlParameter.Optional }
);
}
Please please please do check that the Server has the correct time and date set...
After about wasting 6 hours, i read it somewhere...
The date and time for the server must be updated to work correctly...
otherwise you will get 'Sys' is undefined error.
Hi thanx a lot it solved my issue ,
By default vs 2008 will add
<!--<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false" />-->
Need to correct Default config(Above) to below code
FIX
<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="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>

Resources