在单一服务的ASP.NET Web API的自我主机HTTPS和HTTP? [英] ASP.NET Web API Self-Host both HTTPS and HTTP in single service?

查看:331
本文介绍了在单一服务的ASP.NET Web API的自我主机HTTPS和HTTP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有暴露了两个控制器公众自托管的ASP.NET Web API服务。其中之一,我想只能通过HTTPS有访问,其他的我不知道。这个问题能在一个单一的服务呢?如果是这样,你能不能提供一些线索?好像我需要注册两个基址,但我看不出这有可能为一个单一的服务。

I have a public self-hosted ASP.NET Web API service that exposes two controllers. One of them I would like to have accessible only via HTTPS, and the other I don't. Can this be done within a single service? If so, can you provide a few hints? It seems like I would need to register two base addresses, but I don't see how that's possible for a single service.

推荐答案

您需要创建两个HttpServer的实例,一个用于HTTP,另一个用于HTTPS。我一直在试图找出为什么这个限制,是因为我知道的HttpListener可以处理的相同的侦听器注册。

You need to create two HttpServer instances, one for http and one for https. I've been trying to find out why this limitation exists because I know HttpListener can handle registering both for the same listener.

无论如何,如果创建了两个HttpServer的情况下,确实没有适合你的工作,那么你就需要看看武士刀项目和Microsoft.Owin.HttpListener。这并不支持多个地址,但遗憾的是默认的武士刀启动code不!但我有良好的权力有一种方法可以在启动时,以使其能够自定义的HttpListener。

Anyway, if creating two HttpServer instances really doesn't work for you then you will need to look at the Katana project and the Microsoft.Owin.HttpListener. That does support multiple addresses but unfortunately the default Katana startup code doesn't! But I have it on good authority there is a way to customize the HttpListener on startup to make it possible.

这篇关于在单一服务的ASP.NET Web API的自我主机HTTPS和HTTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆