Eugene
Eugene

Reputation: 219

File cannot be find on website (ASP.NET MVC)

I have web app that write video files to folder inside project

After this it display video to view

With writing is all ok.

But when I try to display video I get this error

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

When I run website on local machine all okay and video is displaying

I face this problem only on hosting (Azure)

Here is code of controller

[HttpPost]
    public ActionResult PostRecordedAudioVideo()
    {
        foreach (string upload in Request.Files)
        {
            var path = AppDomain.CurrentDomain.BaseDirectory + "uploads/";
            var file = Request.Files[upload];

            file?.SaveAs(Path.Combine(path, Request.Form[0]));
        }
        return Json(Request.Form[0]);
    }

Interesting thing in this. I see this file in folder when connect to server via ftp

Here is screenshot enter image description here

But in console I have this enter image description here Where my problem may be?

Upvotes: 2

Views: 144

Answers (2)

Eugene
Eugene

Reputation: 219

Just need to write this in config

<configuration>
<system.webServer>
    <staticContent>
        <remove fileExtension=".webm" />
        <mimeMap fileExtension=".webm" mimeType="video/webm" />
    </staticContent>
</system.webServer>

Upvotes: 0

Niels
Niels

Reputation: 1075

Probably not entirely the answer you're looking for, but you might want to look into storing your video files in Azure blob storage:

  • This current approach is not going to work once your app scales beyond a single node.
  • You will lose uploads if your webapp is redeployed
  • You will run into scale limits quickly, making this potentially very expensive.

If you use blob storage, you offload the video traffic from the webapp by either linking to the file directly in a public container, or by generating a SAS token on-the-fly for controlled access.

Upvotes: 1

Related Questions