Reprinted: ajax.net 1.0 cross-origin access error Solution

Source: Internet
Author: User
Body: Ajax.net 1.0 Official version has been released for a long time , I encountered cross-origin access problems during my first attempt. , The error message is displayed when you click the left mouse button at any position on the page. : "Access Is denied ", Searched , Solution found .

1. x :\ Program Files \ Microsoft ASP. net \ ASP. NET 2.0 Ajax extensions \ v1.0.61025 \ system in microsoftajaxlibrary. web. copy the extensions folder to the project. .

2.Open System. Web. Extensions\ Microsoftajax. JsFile,Locate the case SYS. browser. internetexplorer Section,Replace the content with the followingCode:

Switch (SYS. browser. Agent ){ Case SYS. browser. internetexplorer: SYS. UI. domelement. getlocation = Function (){If (. Self | A. nodetype = 9) Return New SYS. UI. Point (0, 0 ); VaR B = A. getboundingclientrect (); If (! B) Return New SYS. UI. Point (0, 0 ); VaR C =. Document . Documentelement, D = B. Left-2 + C. scrollleft, E = B. Top -2 + C. scrolltop; Try { VaR G = A. ownerdocument. parentwindow. frameelement | Null ; If (G ){ VaR F = 2-(G. frameborder | 1) * 2; D + = f; e + = f }} Catch (H ){} Return New SYS. UI. Point (d, e )}; Break ;

Note that the above Code should be written in one line.

3.Open System. Web. Extensions\ Microsoftajax.Debug. JS,Locate the case SYS. browser. internetexplorer Section,Replace the content with the following code::

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 ;

4.IsScriptmanagerAddScriptreference,Reference the modifiedJSFile:

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

 

ReferenceArticle-1:Http://blog.darkthread.net/blogs/darkthreadtw/archive/2007/04/13/kb-cross-domain-access-denied-issue-of-asp-net-ajax-page.aspx

References-2:Http://weblogs.asp.net/bleroy/archive/2007/01/31/how-to-work-around-the-quot-access-denied-quot-cross-domain-frame-issue-in-asp-net-ajax-1-0.aspx

[Solution to cross-origin access error from ajax.net 1.0]

Category: JS/html/CSS/XML Release date:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.