public void GetAllDistricsWithIdJSON() { if (ApiMethods.IsApiAuthRequest()) { var js = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; var district = new Districts(); var allDistricts = district.GetAllItems(); var allDistrictList = new List <AllDistrictWithIdResult>(); foreach (DataRow row in allDistricts.Tables[0].Rows) { allDistrictList.Add(new AllDistrictWithIdResult() { id = row["ID"].ToString(), name = row["Name"].ToString().Trim(), monday = row["Monday"].ToString().Trim(), tuesday = row["Tuesday"].ToString().Trim(), wednesday = row["Wednesday"].ToString().Trim(), thursday = row["Thursday"].ToString().Trim(), friday = row["Friday"].ToString().Trim(), saturday = row["Saturday"].ToString().Trim(), sunday = row["Sunday"].ToString().Trim() }); } Context.Response.ContentType = "application/json; charset=UTF-8"; var responceBody = js.Serialize(allDistrictList); Context.Response.Write(responceBody); ApiMethods.LoggingRequest("GetAllDistrictWithIdJSON", "CityAPI", "PublicAPI", null, responceBody.Length, Convert.ToInt32(HttpContext.Current.Request.Params["userid"]), HttpContext.Current.Request.Params["apikey"]); } else { ApiMethods.ReturnNotAuth(); } }