Exemple #1
0
        public virtual void Handle(HttpContextBase context)
        {
            try
            {
                string action = context.Request["action"];
                if (!Handlers.ContainsKey(action))
                {
                    throw new InvalidOperationException("Couln't find any handler for the action: " + action);
                }

                IAjaxService service = Handlers[action];

                if (service.RequiresEditAccess && !security.IsEditor(context.User))
                {
                    throw new PermissionDeniedException(null, context.User);
                }

                if (!service.IsValidHttpMethod(context.Request.HttpMethod))
                {
                    throw new HttpException((int)HttpStatusCode.MethodNotAllowed, "This service requires HTTP POST method");
                }

                service.Handle(context);
            }
            catch (Exception ex)
            {
                context.Response.Status = ((int)HttpStatusCode.InternalServerError).ToString() + " Internal Server Error";
                context.Response.Write(WriteException(ex, context.User));
            }
        }
Exemple #2
0
 public virtual string Handle(IRequestParameters requestparams)
 {
     try
     {
         string action = requestparams.ServiceName;
         //get the IAjaxService and  perform the action
         if (Handlers.ContainsKey(action))
         {
             IAjaxService service = Handlers[action];
             //TODO: Add a security check here
             object responseobject = service.Handle(requestparams);
             if (responseobject != null)
             {
                 return(TransformResponse(responseobject, service.OutputType));
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             throw new CuyahogaAjaxException("Couln't find any handler for the action: " + action);
         }
     }
     catch (Exception ex)
     {
         return(String.Concat(ex.Message, " stacktrace:", ex.StackTrace));
     }
 }
Exemple #3
0
        public virtual string Handle(HttpContext context)
        {
            try
            {
                string action = context.Request["action"];
                if (Handlers.ContainsKey(action))
                {
                    IAjaxService service = Handlers[action];

                    if (service.RequiresEditAccess && !security.IsEditor(context.User))
                    {
                        throw new PermissionDeniedException(null, context.User);
                    }

                    string responseText = service.Handle(context.Request.QueryString);
                    return(responseText);
                }
                throw new N2Exception("Couln't find any handler for the action: " + action);
            }
            catch (Exception ex)
            {
                return(WriteException(ex, context.User));
            }
        }