Simple HTTP Listener example


Simple HTTP Listener example

I’ve been having problems with service stack only listening on one port.  Our servicestack has been moved to https but our network load balancer would rather hit an http port, therefore not attracting any SSL overhead.  Servicestack only supports one endpoint, therefore I’ve added a simple HTTP Listener to respond to http://host/ping otherwise redirect to the https service.


Nice easy to follow article on implementing HTTPS with a self hosted app

Pedro Félix's shared memory

In a previous post, I showed how to  self-host ASP.NET Web API. This post shows how to change that example in order to enable HTTPS support.

  1. On an elevated console (“Run as administrator”), execute “netsh http add urlacl url=https://+:4443/ user=<your user name>”, to allow the running user to listen on port 4443 using HTTPS (note the use of ‘https’ instead of ‘http’ in the above command).
  2. Also on an elevated console, register the server certificate by running

    netsh http add sslcert ipport= certhash=thumbprint appid={app-guid} where

    • port is the listening port (e.g. 4443); the special IP address matches any IP address for the local machine;
    • thumbprint is the certificate’s SHA-1 hash, represented in hexadecimal;
    • app-guid is any GUID (e.g. {00000000-0000-0000-0000-000000000000}) , used to identity the owning application.
  3. In the previous post’sMain method, replace the HttpSelfHostConfiguration class…

View original post 48 more words


Really useful paper on session state.


So this question comes up all the time: “Where should I keep my shopping cart data for my application?” The common knee-jerk response is “use session state”. I find this to typically be the wrong answer if you want to build a resilient and scalable application.

Session state was originally meant for this kind of data (user provided data like a shopping cart). One thing session is not meant for is caching of user profile data. Back in classic ASP there were not a lot of other caching per-user data, so session was the obvious choice, but in ASP.NET (and just .NET in general) there are so many better options. One such example is the data cache in ASP.NET. With the data cache you specifically code to deal with failure (the cache item might not be present) and you can also set very specific conditions per cache item designating how…

View original post 1,176 more words

Servicestack, Self Hosting and SSL


I’ve been exploring recently and redesigning our systems architecture around REST principles.  It’s looking good, but a lot to learn!

Additionally the service that’s being developed will be self-hosted .NET (no IIS!) to help making  testing and automated deployment easier.

So gotchas I found already:

When setting up the apphost don’t forget the trailing slash – http://localhost:2013 won’t work http://localhost:2013/ will work!

If you want the service to listen on any host name then set the service up as http://*/ or you could add a port in http://*:2013/

If you want to do SSL then you need to read this article – I’m still working on it!