Это простой фильтр Я написал, чтобы отвечать на все запросы, отличные от https, с запрещенным ответом 403:
Код: Выделить всё
public class HttpsFilter : IAuthorizationFilter {
public bool AllowMultiple {
get {
return false;
}
}
public Task ExecuteAuthorizationFilterAsync( HttpActionContext actionContext, CancellationToken cancellationToken, Func continuation ) {
var request = actionContext.Request;
if ( request.RequestUri.Scheme != Uri.UriSchemeHttps ) {
HttpResponseMessage response = request.CreateResponse( HttpStatusCode.Forbidden );
response.Content = new StringContent( "HTTPS Required", Encoding.UTF8, "text/html" );
actionContext.Response = response;
return new Task( delegate() {
return response;
} );
}
else
return continuation();
}
}
Подробнее здесь: https://stackoverflow.com/questions/159 ... in-web-api
Мобильная версия