public void Run() { httpListener.Start(); while (true) { HttpListenerContext context = httpListener.GetContext(); HttpListenerResponse response = context.Response; _parser.URLParser(context.Request.Url.ToString()); if (_parser.LocalPath.Contains("/api/")) { RESApi method = new RESApi(); string methodName = method.GetMethod(context.Request.HttpMethod, _parser.ApiParser()); if (methodName != "No Such Method") { APIOperation aPIOperation = new APIOperation(); var cleaned_data = _request.GetRequestData(context); JObject jsonObj = JObject.Parse(cleaned_data); Dictionary <string, string> dictObj = jsonObj.ToObject <Dictionary <string, string> >(); string data = ""; foreach (var item in dictObj) { data += item.Value; } var output = aPIOperation.GetType().GetMethod(methodName).Invoke(aPIOperation, new object[] { data }); _responseGenrate.ResponseGenrator(output.ToString(), response); } } else { string page = _dispatch.Applist[_parser.BasePath] + _parser.LocalPath; //Console.WriteLine(page); try { { _website.Handle(_responseGenrate, context, page, response); } } catch { _error.Error404NotFound(_dispatch, _responseGenrate, response, context, page); } } } }