HasXHeader() private method

private HasXHeader ( 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
        void Application_Error(object sender, EventArgs e)
        {
            HttpApplication app     = sender as HttpApplication;
            HttpContext     context = app.Context;

            if (RequestManager.HasXHeader(context.Request))
            {
                DirectResponse responseObject = new DirectResponse(true);
                string         error          = null;

                if (HttpContext.Current != null)
                {
                    error = HttpContext.Current.Error != null?HttpContext.Current.Error.ToString() : null;
                }

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

                    if (error.IsNotEmpty())
                    {
                        responseObject.ErrorMessage = error;
                    }
                    else
                    {
                        responseObject.ErrorMessage = ResourceManager.AjaxErrorMessage;
                    }
                }

                app.Context.Response.Clear();
                app.Context.Response.ClearContent();
                app.Context.Response.ClearHeaders();
                app.Context.Response.StatusCode = (int)HttpStatusCode.OK;
                app.Context.Response.Write(responseObject.ToString());
                app.Context.Response.End();
                app.CompleteRequest();
            }
        }