I have a MVC rest Web API, that have a method that looks like this:

public HttpResponseMessage PostBook(DtoBooks Book)
if (Book == null)
return Request.CreateResponse(HttpStatusCode.BadRequest);
Book.Id = Guid.Empty;
var response = Request.CreateResponse(HttpStatusCode.Created, Book);
return response;

Its hosted on different domain with IIS.

When I want to test to do a post I type following js:

type: “POST”,
url: “http://domain-2:9090/api/Values/”,
dataType: “json”,
data: { CallToActionUrl: ‘http://domain-2/’, Message: ‘Hello World!’, OpenInModal: false, Status: 0, TargetUser: ‘domain2admin’, TimeStamp: ‘2014-02-28′, Type: 0 },
success: function (data) {
error: function (data) {

When I have navigated to http://domain-2:8080/ I can run this ajax and it works perfectly!
But when I try to use it on a different domain lets say domain-3, it fails.

So I can basicly only run the the method when I am actually navigated to the web api url, but I cant when Im on another sites. How can I fix this

Is there any solutions for this? Would appreciate it alot.

Read more here: Cross domain problems with my rest API


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: