示例#1
0
        private void RedirectPreSendRequestHeaders(object sender, EventArgs e)
        {
            HttpApplication app     = sender as HttpApplication;
            HttpContext     context = app.Context;

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

                    AjaxResponse responseObject = new AjaxResponse(true);

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

                    TextWriter writer = context.Response.Output;
                    writer.Write(responseObject.ToString());
                }
            }
        }
示例#2
0
        void Application_Error(object sender, EventArgs e)
        {
            HttpApplication app     = sender as HttpApplication;
            HttpContext     context = app.Context;

            if (Ext.HasXCooliteHeader(context.Request))
            {
                AjaxResponse responseObject = new AjaxResponse(true);
                string       error          = null;
                if (HttpContext.Current != null)
                {
                    error = HttpContext.Current.Error != null?HttpContext.Current.Error.ToString() : null;
                }

                if (!ScriptManager.AjaxSuccess || !string.IsNullOrEmpty(error))
                {
                    responseObject.Success = false;
                    if (!string.IsNullOrEmpty(error))
                    {
                        responseObject.ErrorMessage = error;
                    }
                    else
                    {
                        responseObject.ErrorMessage = ScriptManager.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();
            }
        }