'How to display video that are stored outside the root folder in asp.net mvc

I have to upload video outside the root folder in asp.net mvc and store the name and path of the video in database, and then display all the videos from that folder to UI. So, please help me here is the code, I am able to store the video in particular folder outside the root directory, but while fetching and showing all the video on View, it is not getting fetched.

[HttpPost]
public ActionResult UploadData(HttpPostedFileBase videoFile)
{
  if (videoFile != null)
   {
     string FileContentName = Path.GetFileName(videoFile.FileName);
     string extension = Path.GetExtension(videoFile.FileName);
     if (extension != ".mp4")
       {
         ViewBag.fileError = "Only Video allowed";
         return View(Videos);
        }
        if (videoFile.ContentLength < 104857600)
        {
           string Mypath = @"C:/Contents/UserVideo/";
           videoFile.SaveAs(Mypath + FileContentName);

         using (MySqlConnection Connection = new MySqlConnection(ConnectionString))
                    {
                        string Query = "insert into useruploadvideo (VideoName, VideoPath, USERID) values (@Vname, @Vpath, @USERID)";
                        using (MySqlCommand Command = new MySqlCommand(Query))
                        {
                            Command.Connection = Connection;
                            Connection.Open();
                            Command.Parameters.AddWithValue("@Vname", FileContentName);
                            Command.Parameters.AddWithValue("@Vpath", Mypath + FileContentName);
                            Command.Parameters.AddWithValue("@USERID", UserID);
                            Command.ExecuteNonQuery();
                            Connection.Close();
                            ViewBag.Message = "Record saved Successfully";
                        }
                    }
                }
                else
                {
                    ViewBag.fileError = "Video length should be less than 100 MB";
                    return View(Videos);
                }
            }

Below is the code for View,

@{
    ViewBag.Title = "UploadData";
}

<!DOCTYPE html>

<html>
<head>

    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/MainPage.css" rel="stylesheet" />
</head>
<body>

    <div style="margin-top:30px;"> 
        <center><h2><b>Share Your Video</b></h2></center>
    </div>
    <br />
    <div class="container">
        <div class="UploadByUser">
            @ViewBag.fileError
            @using (Html.BeginForm("UploadData", "UploadYourData", FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                <div class="form-group">
                    <div class="input-group">
                        @Html.TextBox("videofile", "", new { type = "file" })<br />
                        <input type="submit" value="Upload Video File" class="form-control btn btn-primary" />
                    </div>
                </div>
            }
        </div>

        <hr />
        @foreach (var item in Model)
            {
            <div class="col-sm-4 col-md-4 col-xs-12 text-center">

                <div class="video-frame">
                    <video style="width:250px; height:150px" controls>
                        <source src="@Url.Content(@item.VideoPath)" type="video/mp4" />
                    </video>
                </div>

                <center>
                    <div class="title" style="width:300px">
                        <h4>@item.VideoName</h4>
                    </div>
                </center>
                <hr />
            </div>
        }
    </div>
</body>
</html>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source