Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            this.context = context;
            try
            {
                if (string.IsNullOrEmpty(context.Response.Charset))
                {
                    context.Response.Charset = "utf-8";
                }
                context.Response.ContentType = "application/json";

                functionName = Query <string>("sys_method", "").Trim(' ', ',');
                string[]   items = functionName.Split(',');
                JsonHelper js    = null;
                if (items.Length > 1)
                {
                    js = new JsonHelper(false, false);
                }
                foreach (string item in items)
                {
                    string lowerItem = item.ToLower();
                    bool   isAllow   = !WebHelper.IsCheckToken() || UserAuth.IsExistsToken(false);
                    if (isAllow)
                    {
                        if (p == null)
                        {
                            p = new Permission(UserAuth.UserName, false);
                        }

                        MethodInvoke(item);
                        if (items.Length > 1)
                        {
                            js.Add(item, jsonResult);
                        }
                        else
                        {
                            Write(jsonResult);
                        }
                    }
                    else
                    {
                        WriteError(AppConfig.GetApp("UI") + "/login.html");
                        return;
                    }
                }
                if (items.Length > 1)
                {
                    Write(js.ToString());
                }
            }
            catch (ThreadAbortException e)
            {
                //ASP.NET 的机制就是通过异常退出线程(不要觉的奇怪)
            }
            catch (Exception err)
            {
                WriteError(err.Message);
            }

            context.Response.End();
        }