1. 程式人生 > >C# 一般處理程式後臺傳來引數作為方法Act

C# 一般處理程式後臺傳來引數作為方法Act

 private HttpRequest req;
        private HttpResponse res;
        private HttpContext ctx;

        public void ProcessRequest(HttpContext context)
        {

            this.ctx = context;
            this.req = ctx.Request;
            this.res = ctx.Response;
            res.ContentType = "text/plain"
; string act = req["act"]; if (string.IsNullOrEmpty(act)) { res.Write("沒有引數"); } else { Type type = this.GetType(); MethodInfo method = type.GetMethod(act); if (method != null
) { method.Invoke(this, null); } else { res.Write("沒有這個方法"); } } res.End(); }