Base solution for your next web application
Open Closed

No 'Access-Control-Allow-Origin' - WebAPi + Ionic + Angular #1586


User avatar
0
benjamim created

I'm having trouble consuming Web Api with Ionic. I need to install any package or configuration to be able to authenticate and consuming methods of WebAPI?


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Cross-Origin Requests are disabled for WebAPI by default because of security. You can see this to enable it: <a class="postlink" href="http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api">http://www.asp.net/web-api/overview/sec ... in-web-api</a>

    For example, I allowed all cross origin requests in this example project: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-samples/blob/master/SimpleTaskSystem/SimpleTaskSystem.WebSpaAngular/App_Start/SimpleTaskSystemWebModule.cs#L54">https://github.com/aspnetboilerplate/as ... ule.cs#L54</a>