public void ProcessRequest(HttpContext context)
{
DirectResponse responseObject = new DirectResponse(true);
try
{
HandlerMethods handler = HandlerMethods.GetHandlerMethods(context, context.Request.FilePath);
string methodName = HandlerMethods.GetMethodName(context);
if (handler == null)
{
throw new Exception("The Method '{0}' has not been defined.".FormatWith(context.Request.FilePath));
}
if (methodName.IsEmpty())
{
throw new Exception("No methodName has been set in the configuration.");
}
DirectMethod directMethod = handler.GetStaticMethod(methodName);
if (directMethod == null)
{
throw new Exception("The static DirectMethod '{0}' has not been defined.".FormatWith(methodName));
}
responseObject.Result = directMethod.Invoke();
}
catch (Exception e)
{
if (HandlerMethods.RethrowException(context))
{
throw e;
}
responseObject.Success = false;
responseObject.ErrorMessage = IsDebugging ? e.ToString() : e.Message;
}
context.Response.Cache.SetNoServerCaching();
context.Response.Cache.SetMaxAge(TimeSpan.Zero);
context.Response.Write(responseObject.ToString());
context.Response.End();
}