I have an ASP.Net MVC 4 Website
and another ASP.Net Web API
project.Currently both are hosted on different domain.I am using amplify.js
to consume API on my front end.Since both websites are hosted on different domain its always a crossdomain request when i call my API
from the UI
(I am utilizing CORS
for this purpose.).This results in additional OPTIONS
request for each HTTP API
call i make,which increases overhead.I also tried hosting these 2 websites on sub domains but still the OPTIONS
request is there,I want to get rid of these extra request.
Is there any way by which i can eliminate the OPTIONS
request?
Is there any way by which i can eliminate the OPTIONS request?
You could use JSONP
instead of CORS. Unfortunately this might not be sufficient for your scenario because JSONP works only with GET requests (jQuery's $.ajax
method has this limitation).
Or if you host the 2 on the same domain and you are not violating the same origin policy
, you could use a normal AJAX request.