I have a weird issue that only seems to be affecting IE 7. The web site is a 3.5 c# asp.net website that utilizes ajax and the ajax control toolkit deployed to a win 2003 server. Everything appears to be correct in the web.config. In fact, everything works perfectly in IE6 and Firefox 3. It is only in IE7 that I get the dreaded sys is undefined error.
Also, the site appears to be working fine for IE7 on a different installation of the same code. That server is running win 2003 with very similar setups.
Since this appears to be a server issue, are there any kind of settings that would prevent ajax-enabled sites from displaying properly in IE7?
I know you said that everything appears to be correct in web.config, but still check it again on that server for this:
<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"/>
in the <httpHandlers> element.
If it is there, then in IE7 do View Source, and grab one of the ScriptResource.axd script reference URLs and just paste it into the browser and see what it comes back with.
Believe it or not, but emptying the temporary internet files solved the problem. I hate things like this!
I had this error when we moved to a new version of the AJAX Control Toolkit, and the new dll for that library didn't propagate out correctly when I rebuilt. So clearing the temp inet files is what I had to do also.
Are you using the "Combine Scripts" functionality of the AJAX Toolkit Script Manager? It's known to cause problems with some browsers/proxies, leading to the very error you're describing. I think it's enabled by default in 3.5, so you might want to look at shutting it off and seeing if your problems persist.
Are you sure that it is only IE7? Maybe other browsers are supressing the error. Firebug on Firefox might bring this to the surface.
The two times I have seen something like this were
a) using jQuery in the same project as ASP.NET Ajax, here jQuery's noConflict method helped out
b) Check the position of the ScriptManager on your page, make sure that it isn't being included in a Content Page but referenced above in a Master Page or something like that
Hope this helps
Try placing your javascript code below <asp:ToolkitScriptManager>
None of the suggestion worked for me, but when added the following under <system.web>, it worked!
<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>
Related
I have an IIS6 running on Windows Server 2003 (x86) and have written a custom handler (Not a handler for 404 errors).
When I try to access the handler by opening in a browser http://localhost/Priority1.Sync/Transfer.p1s, I get error 404 (404 0 in log file). Other pages in the web application work, e.g. http://localhost/priority1.sync/syncservice.asmx
The handler works fine on my IIS7 dev machine.
web.config is setup as follows:
<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 verb="*" path="*.p1s" type="MCS.Priority1.Sync.WebServices.TransferHandler, SyncService" />
</httpHandlers>
I have set an application extension for "*.p1s" (Default Web Site>Properties>Home Directory>Configuration>Mappings>Add).
Am I missing something else?
Thanks,
Andy
Do you have the "Verify that file exists" option in your custom handler IIS configuration checked or not?
IIS6 expects a physical file to exist by default. If there isn't one, it won't pass the request on to your handler at all. You need to disable this check, so it will send the request to your handler as expected.
IIS6 and IIS7 are fundamentally different beasts. IIS7's managed pipeline means every request hits your registered handlers, in IIS6 only things mapped to ASPNET_ISAPI.DLL (typically *.aspx and *.ashx and other default ASP.NET extensions) get processed.
You can make your IIS7 dev box behave this way by using the "classic" pipeline for your development app pool for this project.
Another trick to making it work how you expect is to map 404 errors to an ASP.NET page and then you can at least get into your handler.
In all honesty I would look towards upgrading production to IIS7 as it is so vastly more capable it isn't even funny.
If you are registering handlers for IIS 6 then do remember they should be placed in the
<httpHandlers> element of <system.web> section of the web.config not the <system.webServer> section that IIS7 uses.
I am migrating a web application (WebForms) from ASP.NET 3.5 on IIS6 to ASP.NET 4.0 on IIS 7.5.
I created a new project in VS2010 and add the existing source files from the old project and compiled. It took a small amount of tweaking but everything compiled fine.
When I run the application via IIS (http://localhost/myapp) I get the following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
The relevant part of the Web.config is:
<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">
...
The error is highlighting the script ResourceHandler
I have done some Googling but cannot find a solution to this problem. Any ideas?
The first thing that pops out at me is that the ScriptResourceHandler block, as well as the others that you've listed, are referencing v3.5 of System.Web.Extensions, where it should be referencing v4 for a .NET 4 application.
(Not all of the .NET 4 framework assemblies have been updated to a v4 version number but this one does.)
It looks like you're working with the the old v3.5 web.config. If so, you may try making a backup of web.config (of course), adding a new, default web.config to the web app, and then adding in any custom settings (appSettings, connectionStrings, etc). That's probably the fastest way to get a correct web.config without having to manually modify each entry, update attribute names, etc.
Also, you may or may not be aware that many IIS settings have been moved into the system.webServer section in web.config in 7.x that were in other sections for IIS6/v3.5. If you start with VS's default v4 web.config, it won't be an issue.
I am getting a "Microsoft JScript runtime error: 'Sys' is undefined" error on one of my pages in an MVC application when I attempt an AJAX call. The AJAX call is made from a partial view which is embedded in more than one page. It works fine on all of the pages except one. I have read posts pointing to the web.config file settings and .axd mappings as possible solutions, but the application is configured correctly in the web.config, and the .axd mappings are also correct in IIS. Plus it works fine on all of the pages that use this partial view except one. It is acting like the AJAX libraries are not loading for this one page.
The references to the script files are in the shared site.master file. All of the pages, including the one that doesn't work, reference the same masterpage.
Any ideas? I have been working on this one for two days now. Thanks.
EDIT: As Sam pointed out below, it would seem like the AJAX call is firing before the AJAX libraries have a chance to load. But, the AJAX call is triggered by a submit button long after the page has rendered, so the AJAX libraries have had plenty of time to load - sorry for not giving enough information the first time.
In web.config add the following line of code under appsettings tag:
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
Just in case... use the following to avoid path issues
<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>"
type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js") %>"
type="text/javascript"></script>
Source: http://msdn.microsoft.com/en-us/library/dd381533.aspx
Thanks,
Arty
Load the page in Firefox, then use Firebug to inspect the page - you will be able to see all the individual scripts that have been loaded, plus all the network requests that were issued, and whether they succeeded or not. This is better than trying to troubleshoot from the server perspective.
If you are using IE8, you can use the Developer Tools window, but I think Firebug is better - both tools support JavaScript debugging though.
The most likely problem is that you are running script in your partial view before the scripts it is dependent on have had a chance to load - make sure that any script calls you have inside your partial view will only run once the page has loaded, and not immediately during loading.
All the above cases are ok.But sometimes developer forget to add javascript files for ajax .So please check that also.
Basically you might be missing: MicrosoftMvcAjax., MicrosoftMvcValidation.debug and MicrosoftMvcValidation JS file references.
Do the below steps:
PM> Install-Package MicrosoftAjax
PM> Install-Package MicrosoftMvcAjax.Mvc5
Include them in bundleconfig like below:
bundles.Add(new ScriptBundle("~/bundles/mvcFoolProof")
.Include("~/Scripts/MicrosoftAjax*",
"~/Scripts/MicrosoftMvcAjax*",
"~/Scripts/MicrosoftMvcValidation*",
"~/Scripts/mvcfoolproof*",
"~/Scripts/MvcFoolproofJQueryValidation*",
"~/Scripts/MvcFoolproofValidation*"));
Now it should work without any errors.
Add to web.cofig in section:
<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"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Regarding your response to Sam, one thing I've noticed in a lot of MVC apps is that people don't know how to deal with the ambiguity of relative paths and the application/runtime. For example, the URL rewriting pretty much guarantees that a particular page can appear at different depths than you anticipated, so ../../images will point somewhere else depending on whether you're looking at /products/widget or /products/widget/12345, even though the view might be the same. As Arty pointed out, the best way to deal with this is to let the engine do the work for you by using a URL utility and application-relative paths that will be fixed up by the application regardless of the context.
I have also found that using the following works with ASP.NET MVC2.
Instead of using MicrosoftMvcAjax.js, you use MicrosoftMvcValidation.js
Hope this helps someone.
This has been bugging me all morning and I can't even figure out where the error is.
In the current web site I am developing (it's not a web application, in case it makes a difference, there are user controls declared as follows:
<controls>
<add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~\controls\TransitLinkAdmin.ascx"/>
<add tagPrefix="uc1" tagName="TransitLinkList" src="~\controls\TransitLinkList.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~\controls\WelcomeMessageAdmin.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~\controls\WelcomeMessageDisplay.ascx"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
So far so good, right?
But when I try to add one of these controls to a page, I get an error telling me that the control cannot be found. So why when I run the page, I can use the control?
The designer is telling me that it cannot find the user control file and it is using the path from the web.config file, so it must be looking at it in some fashion.
If I register the control directly in the page, no problems there.
My assumption (and we now how that works) is that there is some compilation error for the site as a whole that is preventing the intellisense from working.
Thanks in advance, all.
Just a complete guess, but maybe it is because you are using backslashes instead of forward slashes? Try:
<add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~/controls/TransitLinkAdmin.ascx"/>
<add tagPrefix="uc1" tagName="TransitLinkList" src="~/controls/TransitLinkList.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~/controls/WelcomeMessageAdmin.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~/controls/WelcomeMessageDisplay.ascx"/>
Are you using resharper?
I am not sure what version, but somewhere along the way this artifact had happened.
try updating to the last version.
btw they have an early access program where you can download builds (decent quality), and be updatd with the latest features and fixes.
link to early access program
Close visual studio
Move to the location:
In Windows 7:
C:\Users\Pavel\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas
In Windows XP:
C:\Documents and Settings[your username]\Application Data\Microsoft\VisualStudio\10.0\ReflectedSchemas in windows XP
Delete all the files in that folder location. Note that it is completely safe to delete files in this location.
Then reopen visual studio.
This should solve your problem.
I recently inherited a project that was done with the "web site project template" (which I hate by the way). I have always worked with the "web application template" which I love. I'm perplexed by something that I found in the project though. There is custom control instances throughout all the pages like this:
<cc1:MarketingItem runat="server" ID="BannerAd" />
Nothing too fancy there, right? What really irritates me is that it works just fine without any control registration tags at the top of any of the pages for "cc1" or code behind it's just magic! As you can imagine this makes tracking down the locations of these controls more work, and frankly a pain. My question is how is this even possible? And why did Microsoft introduce such an annoying inconsistency with this project template?
You'll likely find it registered in web.config (system.web>pages>controls i believe). You can globaly register controls there just as you would on the page.
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</controls>
</pages>