asp.net cross domain web services/ wcf

I have created a simple wcf / c# web service and have cross domain issue.
And I understood that can be resolved by written codes in Jquery or change browser setting.
Is it any possibility to write codes inside of WCF codes to fix the issue?
LVL 1
ITsolutionWizardAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OriNetworksCommented:
Can you give an example of the code you are using and what error you are receiving?
0
ITsolutionWizardAuthor Commented:
I have below codes with cross domain issue in Chrome and Firefox.
And I did install below links from Chrome but still not working.

However, IE working with enable the cross domain under Internet Option >> Security Tab

Any ideas

function GetModelList(divisCode)
      var customerNo = "315217";            
        var GetModelListJSon = "http://clientaccesstest.abc/GetModel";            
        $(document).ready(function () {
            $.ajax({
                cache: false,
                type: "GET",
                async: false,
                dataType: "json",
                contentType: 'text/plain',
                url: GetModelListJSon + encodeURIComponent("(011,115217)"),
                success: function (data) {
                    $('#data').html(data);
                    if (data == null)
                        return;
                    resultObj = jQuery.parseJSON(data);
                    if (resultObj.Status != 'Failed') {
                        $('#json').html(setModelInfo(resultObj.Data,divisCode));
                    }
                },
                error: function (xhr,status,error) {
                    $('#data').html(xhr.responseText);
                    alert(xhr.responseText + " : error GetModelListJSon");
alert(status);
alert(error);
                }
            });
        });
}


https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en
https://chrome.google.com/webstore/detail/forcecors/oajaiobpeddomajelicdlnkeegnepbin/related?hl=en

http://codedevstuff.blogspot.com/2014/10/use-chrome-for-development-and-allow.html
0
toakkiyadavCommented:
Hi,

I'm not sure how you will consume in WCF but for Web, there is package you can use it.
Alternatively below code also works:

HttpResponseMessage msg;

msg.Headers.Add("Access-Control-Allow-Origin", "*");
msg.Headers.Add("Access-Control-Allow-Credentials", true.ToString());
msg.Headers.Add("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
 msg.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, Location");
msg.Headers.Add("Access-Control-Expose-Headers", "Location");

HTH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITsolutionWizardAuthor Commented:
toakkiyadavm thank you for your codes samples. Actually, I already posted my codes. How should I merge yours to mine?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.