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.

2
  • Try this and let me know. If it works, I'll post it as the answer: <staticContent> <remove fileExtension=".mp4" /> <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> </staticContent> Commented Aug 30, 2016 at 6:44
  • You're welcome. I have posted the answer with some explanations. Commented Aug 30, 2016 at 9:44

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.