Ejemplo n.º 1
0
        private void EndRequestHandler(object sender, EventArgs e)
        {
            // DevDiv 100198: Send error response from EndRequest so Page and Application error handlers still fire on async posts
            // DevDiv 118737: Call Response.Clear as well as Response.ClearHeaders to force status code reset in integrated mode and
            // to ensure there are no errant headers such as a caching policy. Do not call Response.End or app.CompleteRequest as they
            // are pointless from the EndRequest event.
            HttpApplication app     = (HttpApplication)sender;
            HttpContext     context = app.Context;
            object          o       = context.Items[PageRequestManager.AsyncPostBackErrorKey];

            if ((o != null) && ((bool)o == true))
            {
                context.ClearError();
                context.Response.ClearHeaders();
                context.Response.Clear();
                context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                context.Response.ContentType = "text/plain";

                string errorMessage = (string)context.Items[PageRequestManager.AsyncPostBackErrorMessageKey];
                o = context.Items[PageRequestManager.AsyncPostBackErrorHttpCodeKey];
                // o should definitely be an int, but user code could overwrite it
                int httpCode = (o is int) ? (int)o : 500;

                PageRequestManager.EncodeString(context.Response.Output,
                                                PageRequestManager.ErrorToken,
                                                httpCode.ToString(CultureInfo.InvariantCulture),
                                                errorMessage);
            }
        }
Ejemplo n.º 2
0
        private static void HttpResponse_Redirecting(object sender, EventArgs e)
        {
            HttpResponse response = (HttpResponse)sender;
            HttpContext  context  = response.Context;

            // Is in async postback, get status code and check for 302
            if (PageRequestManager.IsAsyncPostBackRequest(new HttpRequestWrapper(context.Request)))
            {
                // Save the redirect location and other data before we clear it
                string            redirectLocation = response.RedirectLocation;
                List <HttpCookie> cookies          = new List <HttpCookie>(response.Cookies.Count);
                for (int i = 0; i < response.Cookies.Count; i++)
                {
                    cookies.Add(response.Cookies[i]);
                }

                // Clear the entire response and send a custom response that the client script can process
                response.ClearContent();
                response.ClearHeaders();
                for (int i = 0; i < cookies.Count; i++)
                {
                    response.AppendCookie(cookies[i]);
                }
                response.Cache.SetCacheability(HttpCacheability.NoCache);
                response.ContentType = "text/plain";

                // DevDiv#961281
                // Allow apps to access to the redirect location
                context.Items[PageRequestManager.AsyncPostBackRedirectLocationKey] = redirectLocation;

                // Preserve redirected state: TFS#882879
                response.IsRequestBeingRedirected = true;

                PageRequestManager.EncodeString(response.Output, PageRequestManager.UpdatePanelVersionToken, String.Empty, PageRequestManager.UpdatePanelVersionNumber);
                // url encode the location in a way that javascript unescape() will be able to reverse
                redirectLocation = String.Join(" ", redirectLocation.Split(' ').Select(part => HttpUtility.UrlEncode(part)));
                PageRequestManager.EncodeString(response.Output, PageRequestManager.PageRedirectToken, String.Empty, redirectLocation);
            }
            else if (RestHandlerFactory.IsRestRequest(context))
            {
                // We need to special case webservice redirects, as we want them to fail (always are auth failures)
                RestHandler.WriteExceptionJsonString(context, new InvalidOperationException(AtlasWeb.WebService_RedirectError), (int)HttpStatusCode.Unauthorized);
            }
        }
Ejemplo n.º 3
0
    //开始统计
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Dictionary <string, int> dic = PageRequestManager.GetPageRequestsStatisticByAccountId(oper.Account.AccountId, this.txtBeginDate.Text.Trim(), this.txtEndDate.Text.Trim());

        if (dic != null && dic.Count > 0)
        {
            string strXML;
            strXML = "<graph caption='流量统计分析' xAxisName='访问日期' baseFontSize='12'  decimalPrecision='0' showNames='1'  pieSliceDepth='30' formatNumberScale='0'>";
            int sunCount = 0;
            foreach (string keyName in dic.Keys)
            {
                if (keyName != null && dic[keyName] != null)
                {
                    strXML += "<set name='" + keyName + "' value='" + dic[keyName] + "' hoverText='流量数:" + dic[keyName] + "'/> ";
                }
            }
            strXML        += "</graph>";
            FCLiteral.Text = FusionCharts.RenderChart("../JS/FusionCharts/Line.swf", "", strXML, "myNext", "650", "330", false, false);
        }
        else
        {
            FCLiteral.Text = "没有数据";
        }
    }