public IActionResult GetItemsBySearchNames([FromBody] string searchname) { IARresponse = BadRequest(); string path = ""; string data = ""; try { ds = db.GetItemsBySearchnames(searchname); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { path = _hostingEnvironment.WebRootPath + "/images/Products/ProductsCategory/ProductsSubCategory/itemimg/" + row["cat_img"].ToString(); byte[] b = System.IO.File.ReadAllBytes(path); data = "data:image/png;base64," + Convert.ToBase64String(b); row["cat_img"] = data; } } IARresponse = Ok(new { res = ds }); } else { IARresponse = Ok(new { res = "" }); } } catch (Exception ex) { IARresponse = BadRequest(new { error = ex.Message }); } return(IARresponse); }