Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
When we access the WEB API service methods from a web application through Ajax calls, will there be any access restrictions for the following scenarios

"HTTPS" Web application accessing an "HTTP" WEB-API
 
"HTTP" Web application accessing an "HTTPS" WEB-API

Will there be any impact on request application or context, either it Http or Https the web API will behave same.

Please advice.


What I have tried:

Access a cross domain web service from a web application using ajax call.

Authentication is denied even after specifying the cross domain feature enabled.

One of my friend suggested there may be issue while accessing a SSL secured Https service from an normal HTTP application.
Posted
Updated 19-Apr-16 8:05am

1 solution

A page served over HTTPS should not be able to access an API served over HTTP, as this would not be secure.

A page served over HTTP will be able to access an API served over HTTPS.

However, this is unlikely to be the problem. It sounds like you're trying to access an API which does not send the Access-Control-Allow-Origin header, and is therefore not available from script running on your page.

If you don't control the site hosting the remote API, your only option is to create a proxy API on your own site which makes the API request from your server. How you do that will depend on what server-side technology you're using.
 
Share this answer
 
Comments
[no name] 19-Apr-16 14:09pm    
Hi Richard,

Yes I understood your point. I was also had same solution to create a proxy service which will be a middle layer between actual service and application.

Is this the only solution or we have any other option to make direct call from application to service?

Thanks.
Richard Deeming 19-Apr-16 14:13pm    
If the remote server doesn't return an appropriate Access-Control-Allow-Origin header, and doesn't provide a JSONP[^] option, then a proxy script is the only solution.
[no name] 19-Apr-16 14:20pm    
Thanks Richard, let me try and update you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900