Walid Ben Miled Walid Ben Miled - 3 months ago 34
reST (reStructuredText) Question

Force HTTP over HTTPS in WEB API DotNet

I have a web api controller and i need to consume it in a Java client but there is problems with the certificate so i need to work with HTTP not HTTPS.

public static class WebApiConfig

public static void Register(HttpConfiguration config)

name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
constraints : null,
defaults: new { id = RouteParameter.Optional }
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"));

public class CommentAPIController : ApiController
IItemService ise = new ItemService();
ICategoryService ice = new CategoryService();
// GET: api/CommentAPI
public IEnumerable<Category> Get()
List<Category> list = new List<Category>();
foreach (Category item in ice.getAllCategory())


return list;

Thanks for help


Please edit the properties of the web api project (right click on the project then properties, or expand the project content and double-click on the Properties group).

Then navigate to the Web screen and see if any of your url points to https.

If yes, please change it to http:// and restart. Normally you have to force https by using [RequireHttps] attribute, so your issue seems the opposite.

According to our discussion in comments. Finally you have been providing wrong port for HTTPS service, which was in the exact screen I pointed you to.

Let's keep it here for the others.