IIS returns 404 not found for .mp4 files

被刻印的时光 ゝ 提交于 2019-12-01 19:12:58

问题


I used hmtl video tag to play video . In my localhost video plays but when I published . It is not played.I have created project based on in ASP.NET. I locally use like this method.

http://localhost:41563/files/Just.mp4

and When I published the url give me an error like this:

  http://111.111.22.22:41563/files/Just.mp4

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

How can I solve this.


回答1:


Check if you have IIS MIME Type for mp4 added for hosted site (or for the directory where you have your video files).

For the Win Server 2012 is is already there but for Win Server 2008 it is not included by default.

So, if you developed/tested on WinSer2012 and then deployed on WinSer2008 then you can have this issue.

The mp4 MIME settings are: File name extension: .mp4 MIME type: video/mp4




回答2:


The MIME type can be added via Web.config as well, just in case your IIS is on Azure:

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

https://blogs.iis.net/bills/how-to-add-mime-types-with-iis7-web-config



来源:https://stackoverflow.com/questions/28274486/iis-returns-404-not-found-for-mp4-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!