HasInputFieldMarker() private method

private HasInputFieldMarker ( HttpRequest request ) : bool
request System.Web.HttpRequest
return bool
Esempio n. 1
0
        private void RedirectPreSendRequestHeaders(object sender, EventArgs e)
        {
            HttpApplication app     = sender as HttpApplication;
            HttpContext     context = app.Context;

            if (context.Response.StatusCode == 302)
            {
                if (RequestManager.HasXHeader(context.Request) || RequestManager.HasInputFieldMarker(context.Request))
                {
                    string url = context.Response.RedirectLocation;
                    context.Response.StatusCode      = 200;
                    context.Response.SuppressContent = false;
                    context.Response.ContentType     = "text/html";
                    context.Response.Charset         = "utf-8";
                    context.Response.ClearContent();

                    DirectResponse responseObject = new DirectResponse(true);

                    responseObject.Script = "window.location=\"".ConcatWith(url, "\";");

                    TextWriter writer = context.Response.Output;
                    writer.Write(responseObject.ToString());
                }
            }
        }
Esempio n. 2
0
        public override void Flush()
        {
            string raw = this.html.ToString();

            StringBuilder buffer = new StringBuilder(256);

            DirectResponse ajaxResponse = new DirectResponse(true);
            HttpContext    context      = HttpContext.Current;

            object isUpdate = context.Items["Ext.Net.Direct.Update"];

            if (isUpdate != null && (bool)isUpdate)
            {
                this.ExtractUpdates(raw, buffer);
            }

            string dynamicHtml = this.ExtractDynamicHtml(raw);

            object isManual = context.Items["Ext.Net.Direct.Response.Manual"];

            if (isManual != null && (bool)isManual)
            {
                if (raw.StartsWith("<Ext.Net.Direct.Response.Manual>"))
                {
                    string script = dynamicHtml.ConcatWith(raw.RightOf("<Ext.Net.Direct.Response.Manual>").LeftOf("</Ext.Net.Direct.Response.Manual>"));
                    byte[] rsp    = System.Text.Encoding.UTF8.GetBytes(script);
                    this.response.Write(rsp, 0, rsp.Length);
                    this.response.Flush();
                    return;
                }
            }

            buffer.Append(dynamicHtml);

            string error = context == null ? null : (context.Error != null ? context.Error.ToString() : null);

            if (!ResourceManager.AjaxSuccess || error.IsNotEmpty())
            {
                ajaxResponse.Success = false;

                if (error.IsNotEmpty())
                {
                    ajaxResponse.ErrorMessage = error;
                }
                else
                {
                    ajaxResponse.ErrorMessage = ResourceManager.AjaxErrorMessage;
                }
            }
            else
            {
                if (ResourceManager.ReturnViewState)
                {
                    ajaxResponse.ViewState          = AjaxRequestFilter.GetHiddenInputValue(raw, BaseFilter.VIEWSTATE);
                    ajaxResponse.ViewStateEncrypted = AjaxRequestFilter.GetHiddenInputValue(raw, BaseFilter.VIEWSTATEENCRYPTED);
                    ajaxResponse.EventValidation    = AjaxRequestFilter.GetHiddenInputValue(raw, BaseFilter.EVENTVALIDATION);
                }

                object obj = ResourceManager.ServiceResponse;

                if (obj is Response)
                {
                    ajaxResponse.ServiceResponse = new ClientConfig().Serialize(obj);
                }
                else
                {
                    ajaxResponse.ServiceResponse = obj != null?JSON.Serialize(obj) : null;
                }

                if (ResourceManager.ExtraParamsResponse.Count > 0)
                {
                    ajaxResponse.ExtraParamsResponse = ResourceManager.ExtraParamsResponse.ToJson();
                }

                if (ResourceManager.DirectMethodResult != null)
                {
                    ajaxResponse.Result = ResourceManager.DirectMethodResult;
                }

                buffer.Append(raw.RightOf("<Ext.Net.Direct.Response>").LeftOf("</Ext.Net.Direct.Response>"));

                if (buffer.Length > 0)
                {
                    ajaxResponse.Script = "<string>".ConcatWith(buffer.ToString());
                }
            }

            bool isUpload = context != null && RequestManager.HasInputFieldMarker(context.Request);

            byte[] data = System.Text.Encoding.UTF8.GetBytes((isUpload ? "<textarea>" : "") + ajaxResponse.ToString() + (isUpload ? "</textarea>" : ""));
            this.response.Write(data, 0, data.Length);

            this.response.Flush();
        }