0

I have started to try to use video in my MVC project for the first time, using the html video tag. I've used a sample local mp4 file to test things out.

            <video controls="controls" width="500" id="video_contract">
                <source src="~/videos/samplevideo.mp4" type="video/mp4" />
            </video>

I couldn't get the mp4 to play and read that I had to use a mimeMap in the web.config file, as follows:

<staticContent>
     <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>

Once my project was published the video was fine in the test published project.

The problem is that my local development project stopped rendering images etc. I have researched the problem and found this MVC CSS not rendering in Visual Studio When debugging .

As per the instruction I removed the mimeMap command and all was good again. I still need to be able to show mp4 video, so how do I get around this problem?

Apologies if I have missed something obvious, but I am still new to ASP.net programming.

Thanks.

Community
  • 1
  • 1
Ste
  • 59
  • 2
  • 10

1 Answers1

0

Before adding mime types into your application, it's better to remove the type you are adding first:

<staticContent> 
    <remove fileExtension=".mp4" /> 
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> 
</staticContent>

This is to avoid any conflict if the mime type is already configured on the server you are deploying to.


OR you can manually add or remove mime types on IIS enter image description here

Click on Mime Types -> Open Feature

enter image description here

adiga
  • 34,372
  • 9
  • 61
  • 83