public void FailedAuthenticationResponse(ChannelAuthenticationSchemes ChannelSchema, HttpListenerResponse response) { LogChannel.Write(LogSeverity.Info, "Authentication failed...Exiting"); IChannelMessage msg = new ChannelMessage() { Success = false, Message = $"You need to provide {ChannelSchema.ToString()} authentication" }; string outputString = JsonConvert.SerializeObject(msg, Formatting.Indented); using (StreamWriter writer = new StreamWriter(response.OutputStream)) { writer.WriteLine(outputString); } }