public void ProcessRequest(HttpContext context)
        {
            try
            {
                compositionRoot = CompositionRootHelper.GetCompositionRoot(context);

                var action = context.Request["action"];

                if (!string.IsNullOrEmpty(action))
                {
                    string response = string.Empty;
                    if (action == GetAction)
                    {
                        response = GetResponse();
                    }
                    else if (action == SaveAction)
                    {
                        Save(context.Request.Params["data"]);
                    }

                    context.Response.StatusCode = 200;
                    context.Response.Clear();
                    context.Response.ContentType = "text/plain";
                    if (string.IsNullOrEmpty(response))
                    {
                        response = "\n";
                    }

                    context.Response.Write(response.ToJSON());
                }
            }
            catch (Exception exc)
            {
                context.Response.StatusCode = 400;
                context.Response.Write(exc.Message);
                throw;
            }
        }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     compositionRoot = CompositionRootHelper.GetCompositionRoot(Context);
 }
 public static void SetCompositionRoot(CompositionRoot value, HttpContext context)
 {
     HttpContext.Current.Application["compositionRoot"] = value;
 }