ASP.net Ajax issue
I am working on an asp.net web application which uses a fair bit of Ajax - nothing too complex just update panels and the controls from the Ajax Toolkit. Prior to being handed over it was using Ajax 1.0 and was then upgraded to work on the 3.5 framework. The toolkit controls were replaced by the correct version and I can create a new page within the project with update panels, a script manager and a modal popup extender, all of which work fine.
The Ajax on some of the existing pages has suddenly stopped working however - I have 3 masterpages and thought it was one of them however the issue now seems to have 'spread' to another one. I have tested the MasterPages (which is where the scriptManager is placed) and this is also working fine.
When I load one of the offending pages and check the Firefox Error Console there are quite a few issues, primarily:
Sys.Res is undefined
Sys.Application is undefined
Sys.UI.DomEvent is undefined
This all seems to suggest to me that for some reason the Ajax library is not getting loaded on these pages however I can't figure out why? Has anyone come up against a similar issue before?
Update
most of the pages simply display UserControls which in turn contain the content including all of the Ajax. One of the pages which doesn't work consists of just 1 UserControl. If i create a new page and name it something different (e.g. testpage1.aspx), use the same MasterPage and then drag the control on it works fine. All of the Ajax works as expected.
If I then delete the page which doesn;t work, create a new page of the same nakme and follow exactly the same steps to add the UserControl it then doesn't work. I have tried clearing down the Website Cache in C:\Users\\AppData\Local\Microsoft\WebsiteCache but this has made no difference.
I have actually tried creating a page with the same name as one of the non working pages and ensuring it is identical, in a different folder. This page works fine however if I then delete the non working page and copy this one into the folder it then doesn't work!!! Is there another cache anywhere?
Further update
The Ajax seems to stop working when 开发者_如何学编程it is a specific folder of the website - this is just a standard folder with a web.config for forms auth in which looks like the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<allow roles="Master Admin" />
<allow roles="Introducer" />
<deny users="*" />
</authorization>
</system.web>
</configuration>
Could the forms auth be preventing the script form loading?
Try replacing the ScriptManager control with a ToolkitScriptManager control.
Something else to try: In the global.asax, handle the AuthenticateRequest event, and see if the file gets requested. For example:
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
if(Request.Path.ToLower.EndsWith(".axd"))
{
Context.SkipAuthorization = true;
return;
}
}
I resolved thisin the end however I am still none the wiser as to why the issue occurred. To fix it I had to copy the pages out into a new folder, delete the old folder and then rename the new one to match the old one??
精彩评论