예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //接收消息指令
            string postString = string.Empty;

            if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
            {
                using (Stream stream = HttpContext.Current.Request.InputStream)
                {
                    Byte[] postBytes = new Byte[stream.Length];
                    stream.Read(postBytes, 0, (Int32)stream.Length);
                    postString = Encoding.UTF8.GetString(postBytes);
                    if (postString == "")
                    {
                        Response.End();
                    }
                    ;
                }
            }
            postString = System.Web.HttpUtility.UrlDecode(postString);

            //替换部分SQL关键字,预防SQL注入
            string SQLReplace = ConfigurationManager.AppSettings["SqlReplace"].ToString();

            string[] SQLReplaces = SQLReplace.Split(',');
            foreach (string item in SQLReplaces)
            {
                postString = postString.Replace(item, "");
            }

            string[] strArr = postString.Split('臡');

            String methodName = strArr[0];//方法名
            String BLL        = strArr[1];
            object Para       = strArr[2];

            try
            {
                BeforeInvoke(BLL);
                string json = BLL_PubClass.PubMethod(methodName, BLL, Para);
                Response.Write(json);
            }
            catch (Exception ex)
            {
                String json = JSON.Encode(ex.Message);
                Response.Write(json);
            }
            finally
            {
                AfterInvoke();
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string postString = string.Empty;
            string Data       = context.Request["Data"].ToString();

            postString = System.Web.HttpUtility.UrlDecode(Data);
            //替换部分SQL关键字,预防SQL注入
            string SQLReplace = ConfigurationManager.AppSettings["SqlReplace"].ToString();

            string[] SQLReplaces = SQLReplace.Split(',');
            foreach (string item in SQLReplaces)
            {
                postString = postString.Replace(item, "");
            }

            string[] strArr = postString.Split('臡');

            String methodName = strArr[0];//方法名
            String BLL        = strArr[1];
            object Para       = strArr[2];

            try
            {
                BeforeInvoke(BLL);
                string json = BLL_PubClass.PubMethod(methodName, BLL, Para);
                context.Response.Write(json);
            }
            catch (Exception ex)
            {
                String json = JSON.Encode(ex.Message);
                context.Response.Write(json);
            }
            finally
            {
                AfterInvoke();
            }
        }