Invoke() public abstract method

public abstract Invoke ( HttpRequest request, HttpResponse response ) : void
request HttpRequest
response HttpResponse
return void
Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            response.ContentType =
                _logicalMethodInfo.ScriptMethod.ResponseFormat == ResponseFormat.Json ?
                "application/json" : "text/xml";
            response.Cache.SetCacheability(HttpCacheability.Private);
            response.Cache.SetMaxAge(TimeSpan.Zero);

            IDictionary <string, object> @params =
                "GET".Equals(request.RequestType, StringComparison.OrdinalIgnoreCase)
                                ? GetNameValueCollectionDictionary(request.QueryString) :
                (IDictionary <string, object>)JavaScriptSerializer.DefaultSerializer.DeserializeObjectInternal
                    (new StreamReader(request.InputStream, request.ContentEncoding));

            try {
                _logicalMethodInfo.Invoke(@params, response.Output);
            }
            catch (TargetInvocationException e) {
                response.AddHeader("jsonerror", "true");
                response.ContentType = "application/json";
                response.StatusCode  = 500;
                JavaScriptSerializer.DefaultSerializer.Serialize(new ExceptionSerializer(e.GetBaseException()), response.Output);
                response.End();
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            response.ContentType =
                _logicalMethodInfo.ResponseFormat == ResponseFormat.Json ?
                "application/json" : "text/xml";
            response.Cache.SetCacheability(HttpCacheability.Private);
            response.Cache.SetMaxAge(TimeSpan.Zero);

            try {
                _logicalMethodInfo.Invoke(request, response);
            }
            catch (TargetInvocationException e) {
                response.AddHeader("jsonerror", "true");
                response.ContentType = "application/json";
                response.StatusCode  = 500;
                JavaScriptSerializer.DefaultSerializer.Serialize(new ExceptionSerializer(e.GetBaseException()), response.Output);
                response.End();
            }
        }