public void ProcessRequest(HttpContext context)
        {
            if (context.Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase))
            {
                context.Response.Clear();
                context.Response.ContentType = "application/json";

                try
                {
                    string authToken        = context.Request["AuthToken"];
                    string antiForgeryToken = context.Request["AntiForgeryToken"];

                    string csv = ReadFile(context.Request.Files["CSV"]);

                    var response = new ApplicantService().ParseApplicantsCSV(new ParseApplicantsCSVRequest
                    {
                        AuthToken        = authToken,
                        AntiForgeryToken = antiForgeryToken,
                        CSV = csv,
                    });

                    var serializer = new DataContractJsonSerializer(typeof(ParseApplicantsCSVResponse));
                    serializer.WriteObject(context.Response.OutputStream, response);
                }
                catch (Exception ex)
                {
                    var serializer = new DataContractJsonSerializer(typeof(Message));

                    string errorMessage;

                    if (ex is WebFaultException <string> )
                    {
                        errorMessage = (ex as WebFaultException <string>).Detail;
                    }
                    else
                    {
                        errorMessage = ex.Message;
                    }

                    serializer.WriteObject(context.Response.OutputStream, new Message {
                        ErrorMessage = errorMessage
                    });
                }
                finally
                {
                    context.Response.End();
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase))
            {
                context.Response.Clear();
                context.Response.ContentType = "application/json";

                try
                {
                    string authToken = context.Request["AuthToken"];
                    string antiForgeryToken = context.Request["AntiForgeryToken"];

                    string csv = ReadFile(context.Request.Files["CSV"]);

                    var response = new ApplicantService().ParseApplicantsCSV(new ParseApplicantsCSVRequest
                    {
                        AuthToken = authToken,
                        AntiForgeryToken = antiForgeryToken,
                        CSV = csv,
                    });

                    var serializer = new DataContractJsonSerializer(typeof(ParseApplicantsCSVResponse));
                    serializer.WriteObject(context.Response.OutputStream, response);
                }
                catch (Exception ex)
                {
                    var serializer = new DataContractJsonSerializer(typeof(Message));

                    string errorMessage;

                    if (ex is WebFaultException<string>)
                    {
                        errorMessage = (ex as WebFaultException<string>).Detail;
                    }
                    else
                    {
                        errorMessage = ex.Message;
                    }

                    serializer.WriteObject(context.Response.OutputStream, new Message { ErrorMessage = errorMessage });
                }
                finally
                {
                    context.Response.End();
                }
            }
        }