Last post Dec 18, 2014 01:14 AM by Shawn - MSFT
Dec 17, 2014 01:40 AM|rohitpundlik|LINK
Can we call web api with Https protocol instead of Http ?? If yes, then how can we ?
I have tried with Https; But it is not calling my web api method.
Any help on this appreaciated.
Dec 17, 2014 02:25 AM|Glenn Saint|LINK
Hi there, the server you hosted your web api (e.g. IIS) should be configure to do https. If your using IIS, please check the following links on how to setup HTTPS in IIS:
Dec 18, 2014 01:14 AM|Shawn - MSFT|LINK
In many cases you will have both HTTP and HTTPS bindings to your website and you may want to ensure that Web API is called only over HTTPS. To accomplish this task you need to create a custom authorization filter. So, add a class in the Web API project,
name it as UseSSLAttribute. Inherit UseSSLAttribute class from AuthorizationFilterAttribute class.
public class RequireHttpsAttribute : AuthorizationFilterAttribute
public override void OnAuthorization(HttpActionContext actionContext)
if (actionContext.Request.RequestUri.Scheme != Uri.UriSchemeHttps)
actionContext.Response = new HttpResponseMessage(System.Net.HttpStatusCode.Forbidden)
ReasonPhrase = "HTTPS Required"
For more information, you could try to refer to: