web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

XmlHttpRequest CORS Issue while accessing Cross domain request

(0) ShareShare
ReportReport
Posted on by 60

I have tried many ways to resolve the CORS issue by following several blogs but was unsuccessful. Please suggest if you find any answer.

The Issue is when i upgraded from IE 11 to Edge by Chromium.

I am working on Dynamics 365 CRM Onpremise. We host external web application in CRM. Both will be on same server but different port. When I try to access external Web pages, it asks for authentication and everything is good. But when I make XmlHttpRequest to call json functions in my external web project, I get this error:

"Access to XMLHttpRequest at 'http://{server}:{port}/{org}/{controller}/{function_name}' from origin 'http://{server}' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status."

I tried to add site in trusted sites n IE and import settings on EDGE from Internet Explorer. This did not fix the issue.

I get the same issue on chrome as well. I did not get this issue with Internet Explorer.

Sample Call in javascript on CRM: CRM and web application is on same server but different port. In this example, I am calling a method in my web project to do something on form save.

var req = new XMLHttpRequest();

    req.open("POST", encodeURI("http://{server}:{port}/{org}/{controller}/{function_name}"), false);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    var data = JSON.stringify({
        id: someguid
    });
    req.onreadystatechange = function () {
        if (this.readyState == 4) {
            req.onreadystatechange = null;
            if (this.status == 200) {
                var result = JSON.parse(req.response);                    
            } else {
                var error = JSON.parse(this.response).error;
                console.log(error);
            }
        }
    };
    req.send(data);

I have the same CORS issue with Iframe as well. I have an Iframe on the CRM form. It points to a web page on my web project. Note this Iframe does not point to html webresource. On load of CRM form, I load the IFRAME with webpage which is on external port. So, here I will be asked for Authentication from web project and IFRAME loads fine.
But when CRM form tries to access any field on IFRAM using:  iFrame.getObject().contentWindow.document.getElementById does not work.
And when IFRAME tries to access Parent form by using: window.parent.Xrm.Page, this gives me CORS issue.

I followed ASP.net web application Enable CORS by giving this in my web.config

<system.webServer>  

<httpProtocol>  

      <customHeaders>  

       <add name="Access-Control-Allow-Headers" value="accept, content-type" />  

        <add name="Access-Control-Allow-Origin" value="*" />  

        <add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />  

      </customHeaders>  

    </httpProtocol>  

  </system.webServer>  





I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 119

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans