KB-cross-domain access denied issue of ASP. NET Ajax page
The website was upgraded to ASP. NET Ajax with no certificate available on the website. Today, the program was only online, and I have published three articles on the website.
The new website is placed in a frame in the first frame. What's terrible is that the first frame is different from the new server, as long as you press the mouse left button anywhere on the new website, a javascript error "access is denied" is reported. I caught up and found the problem on microsoftajax. js. There is a piece of code... (The problem lies in the 5959 column)
Switch (SYS. browser. Agent ){
Case SYS. browser. internetexplorer:
SYS. UI. domelement. getlocation = function sys $ UI $ domelement $ getlocation (element)
... Omitted...
VaR offsetl = W. screenleft-top. screenleft-top.document.doc umentelement. scrollleft + 2;
... Omitted...
If no, top objects are randomly added. When a webpage is embedded in a frame or IFRAME of different domains, no problem occurs! It is also strange that the website and the portal are on the same host before the login. There is no cross-domain problem, and the website can be accessed without failure.
Fortunately, I am not the only victim of this stinking bug. On the Internet, I have already worked hard to find a solution. The major concern is to disable the problematic microsoftajax. js and change it to our own version. Ajax JS libraries are already hidden in DLL using embedded resource, and retrieved using scriptresource. axd. Fortunately, scriptmanager provides a way to switch to the zookeeper solution case by first accessing the Microsoft Ajax library, and resolving the problem after your web application project appears, next, modify the announcement of scriptmanager:
<Asp: scriptmanager id = "scriptmanager1" runat = "server"> <scripts>
<Asp: scriptreference
Name = "microsoftajax. js" scriptmode = "Auto"
Path = "~ /[Webapppath]/system. Web. Extensions/1.0.61025.0/microsoftajax. js "/>
</Scripts> </ASP: scriptmanager>
In this way, scriptmanager replaces the version of embedded in the DLL with webapppath/system. Web. Extensions/1.0.61025.0/microsoftajax. Debug. js. The next step is to modify the program and convert the program "case SYS. browser. internetexplorer" to "case SYS. browser. Safari" to the following method:
Sys.UI.DomElement.getLocation = function(element) {
if (element.self || element.nodeType === 9) return new Sys.UI.Point(0,0);
var clientRect = element.getBoundingClientRect();
if (!clientRect) {
return new Sys.UI.Point(0,0);
}
var ownerDocument = element.document.documentElement;
var offsetX = clientRect.left - 2 + ownerDocument.scrollLeft,
offsetY = clientRect.top - 2 + ownerDocument.scrollTop;
try {
var f = element.ownerDocument.parentWindow.frameElement || null;
if (f) {
var offset = 2 - (f.frameBorder || 1) * 2;
offsetX += offset;
offsetY += offset;
}
}
catch(ex) {
}
return new Sys.UI.Point(offsetX, offsetY);
}
break;
After the modification is completed, no response is sent! Case closed.
We hope that ASP. net ajax can quickly release the service pack.
Published 13 limit l 2007 am by Jeffrey filed under: ASP. NET, kb, Ajax