简体   繁体   中英

Angularjs with Post requests

I already have a project in Asp.Net MVC 5 and C# which is currently running on production.

Now i have created a separated project of angularjs which is for mobile devices, I am unable to send post web api call from angular becoz of "Cross domain" access.

Can somebody suggest me what do do.

  1. If their is any architecture change need to do to achieve such functionality.
  2. any way to call ajax post outside domain.

What version of Web API are you using? You might be able to use CORS which is really easy to implement and you won't have to change your architecture to implement it. Look at this article to help you out Look at this article to help you out

If that isn't able you help you, you can use Jsonp to call your web service from angular js. There's a few tricks with it but it will solve the cross domain problem. Using jsonp in angular js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM