In this article I will explain with an example, how to capture still image / photo / picture from Web Camera (Webcam) without using Flash in ASP.Net MVC Razor.
jQuery Webcam plugin is used to capture images (photos) from Web Camera (Webcam) using HTML5.
The images (photos) captured using Web Camera (Webcam) will be saved in folder and displayed in View in ASP.Net MVC Razor.
jQuery Webcam Plugin
You will need to download the jQuery Webcam.js plugin from the following location, it is also available in the attached source code of this article.
HTML Markup
The View consists of an HTML DIV for the displaying the Live Web Camera, an HTML Image element for displaying the captured image, a Button for capturing the picture using the Web Camera and an HTML Button for capturing the picture using the Web Camera.
Applying the jQuery Webcam.js plugin
Inside the jQuery document ready event handler, the jQuery Webcam.js plugin is applied to the HTML DIV.
The following are the configuration properties of the jQuery Webcam.js plugin.
1. width – Width of the DIV that displays the live camera.
2. height – Height of the DIV that displays the live camera.
3. image_format – The file format of the Image i.e. JPEG, PNG, etc.
4. jpeg_quality – The quality of the captured Image.
Capturing the Image from Web Camera (Webcam)
When the Capture Button is clicked, the Image is captured from Web Camera (Webcam) using the snap function of the jQuery Webcam.js plugin.
Then the captured Image data in BASE64 string format is assigned to the HTML Image element.
Uploading the Image from Web Camera (Webcam)
When the Upload Button is clicked, the captured Image data in BASE64 string format is uploaded to Server using jQuery AJAX call and then inside the SaveCapture Action method, it is converted into Image file and saved in Folder (Directory).
    Layout = null;
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width"/>
    <style type="text/css">
        body {
            font-family: Arial;
            font-size: 10pt;
    <table border="0" cellpadding="0" cellspacing="0">
            <th align="center"><u>Live Camera</u></th>
            <th align="center"><u>Captured Picture</u></th>
            <td><div id="webcam"></div></td>
            <td><img id="imgCapture"/></td>
            <td align="center">
                <input type="button" id="btnCapture" value="Capture"/>
            <td align="center">
                <input type="button" id="btnUpload" value="Upload" disabled="disabled"/>
    <script type="text/javascript" src=""></script>
    <script src="~/Webcam_Plugin/webcam.js"></script>
    <script type="text/javascript">
        $(function () {
                width: 320,
                height: 240,
                image_format: 'jpeg',
                jpeg_quality: 90
            $("#btnCapture").click(function () {
                Webcam.snap(function (data_uri) {
                    $("#imgCapture")[0].src = data_uri;
            $("#btnUpload").click(function () {
                    type: "POST",
                    url: "/Home/SaveCapture",
                    data: "{data: '" + $("#imgCapture")[0].src + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (r) { }
The Controller consists of three Action methods.
Action method for handling GET operation
Inside this Action method, simply the View is returned.
HTTP POST Action method for saving the Captured Image
The Captured Image is received in BASE64 string format.
The BASE64 string is converted into a Byte Array and the Byte Array is saved as Image file in the Folder (Directory).
Note: The return type of this Action method is set as ContentResult as it simply returns a string. For more details, please refer my article ASP.Net MVC ContentResult Example.
public class HomeController : Controller
    // GET: Home
    public ActionResult Index()
        return View();
    public ContentResult SaveCapture(string data)
        string fileName = DateTime.Now.ToString("dd-MM-yy hh-mm-ss");
        //Convert Base64 Encoded string to Byte Array.
        byte[] imageBytes = Convert.FromBase64String(data.Split(',')[1]);
        //Save the Byte Array as Image File.
        string filePath = Server.MapPath(string.Format("~/Captures/{0}.jpg", fileName));
        System.IO.File.WriteAllBytes(filePath, imageBytes);
        return Content("true");
ASP.Net MVC: [Non-Flash] Capture Image (Photo) from Web Camera (Webcam)C
Browser Compatibility

The above code has been tested in the following browsers only in versions that support HTML5.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.