void IHttpHandler.ProcessRequest(HttpContext ctx) { try { if (ctx.Request.Url.GetComponents(UriComponents.Path, UriFormat.Unescaped).ToLower().EndsWith("/ui")) { UI.ProcessRequest(ctx); } else { string reqPayload; using (StreamReader reader = new StreamReader(ctx.Request.InputStream)) reqPayload = reader.ReadToEnd(); ICommand command = (ICommand)SerializationUtil.DeserializeBase64(reqPayload); Response response = command.Execute(ctx); ctx.Response.Write(SerializationUtil.SerializeBase64(response)); } } catch (Exception error) { var errorResponse = new ErrorResponse() { Message = error.Message, ExceptionType = error.GetType().FullName, StackTrace = error.StackTrace }; ctx.Response.Write(SerializationUtil.SerializeBase64(errorResponse)); } }