Display captured Image from WebCam (Web Camera) without saving in folder (disk) in ASP.Net

on Mar 30, 2015 12:37 AM

In reference to your article :


Please tell me how to capture the image and show in image control to user without saving in folder.

Just capture and show.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Mar 30, 2015 02:10 AM

You can convert the bytes to base64 and then save in session and it will display mage without saving.

protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        if (Request.InputStream.Length > 0)
            using (StreamReader reader = new StreamReader(Request.InputStream))
                string hexString = Server.UrlEncode(reader.ReadToEnd());
                string imageName = DateTime.Now.ToString("dd-MM-yy hh-mm-ss");
                string imagePath = string.Format("~/Captures/{0}.png", imageName);
                byte[] bytes = ConvertHexToBytes(hexString);
                string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                Session["CapturedImage"] = "data:image/png;base64," + base64String;