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.
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
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.
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.
Because HttpListenerBase (of ServiceStack.Host.HttpListener) does not override its Listener if not-null when starting then the following could be done in your host class which inherits from HttpListenerBase: