The batch request for WebAPI services triggered correctly for get, put, post and delete method.
When the go ahead and run the same service for the cross origin i am having the following issue.
Failed to load http://localhost:63187/api/batch: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:56126' is therefore not allowed access. The response had HTTP status code 400.
The ajax request will be like this
{
contentType:
"multipart/mixed; boundary="batch_9de42638-127f-4f00-b2df-1dd93b8b8eeb""
data:
"--batch_9de42638-127f-4f00-b2df-1dd93b8b8eeb
↵Content-Type: application/http; msgtype=request
↵
↵PUT http://localhost:63187/put HTTP/1.1
↵Content-Type: application/json; charset=utf-8
↵Host: localhost:56126
↵
↵{"EmployeeID":4,"FirstName":"kalai","LastName":"Peacock","City":"London"}
↵--batch_9de42638-127f-4f00-b2df-1dd93b8b8eeb
↵Content-Type: application/http; msgtype=request
↵
↵PUT http://localhost:63187/put HTTP/1.1
↵Content-Type: application/json; charset=utf-8
↵Host: localhost:56126
↵
↵{"EmployeeID":2,"FirstName":"fdsfsda","LastName":"Fuller","City":"London"}
↵--batch_9de42638-127f-4f00-b2df-1dd93b8b8eeb--
↵"
type: "POST"
url: "http://localhost:63187/api/batch"
}
As well as i have enable the cross origin in the webapi service.
I have installed webapi cross origin support package.
Install-Package Microsoft.AspNet.WebApi.Cors
and i have enabled the cross origin in webapi register as below.
config.EnableCors();
In the webapi controller i have enabled the all origin support
[EnableCors(origins: "*", headers: "*", methods: "*")]
Where did i made a mistake.