用编程方式给IIS增加MIME类型
2008-02-12 16:55
495 查看
前段时间,在完成FLV视频播放,遭遇一个“在服务器上无法播放FLV视频”问题。奇怪的是在我本机上试验是可以的,当放到服务器上就不行。(程序运行环境:windows 2003 +IIs 6.0)
刚开始以为可能是FLV视频文件太大,导致IIS不能下载FLV视频,不能播放。于是修改了IIS附件下载限制,可是到最终在服务器上还是不能播放FLV视频。后来在网络上看到IIS是不支持播放Flash视频,这下可槽糕了,但怎么想也想不通啊,很多视频网站基本上都采用FLASH播放,他们是怎么做到的呢。通过网上资料,最终寻找到ADOBD公司给出“Windows 2003 Server does not stream FLV videos”解决方案:(原文如下:http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19439&sliceId=1)
Please be aware that these steps do not resolve any issue with Flash, but are a configuration step for Microsoft Windows 2003 and Microsoft IIS Server 6.0. Any difficulties in executing these instructions or any errors that may arise from modifying your system settings should be addressed to Microsoft. For more details, please refer to your IIS documentation.
On the Windows 2003 server, open the Internet Information Services Manager.
Expand the Local Computer Server.
Right-click the local computer server and select Properties.
Select the MIME Types tab.
Click New and enter the following information:
Associated Extension box: .FLV
MIME Type box:flv-application/octet-stream
Click OK.
Restart the World Wide Web Publishing service.
设置好后,播放器果然可以播放了。到目前为止,可能有人会问,好像跟该文章主题“用编程方式给IIS增加MIME类型”,没有多大关系吧。好,现在就开始进入正题,既然可以手动设置IIS的MIME类型,那能不能通过程序方式自动给IIS添加MIME类型。那答案是肯定的。只要能获取到IIS控制台的MIME属性就OK了。
IIS的所有操作都可以由System.DirectoryServices来完成。同样地,MIME也应该是可以的,在MSDN中找到一篇关于“Setting MIME Type Properties Using System.DirectoryServices”文章,原文如下http://msdn2.microsoft.com/en-us/library/ms525901.aspx)关键的地方就是引用了Active DS IIS Namespace Provider。这样就得到了IISOLE.IISMimeType类。
具体代码如下:
以上代码在WINDWOS2003 + Visual Studio 2008 + IIS 6.0环境中,测试通过。
刚开始以为可能是FLV视频文件太大,导致IIS不能下载FLV视频,不能播放。于是修改了IIS附件下载限制,可是到最终在服务器上还是不能播放FLV视频。后来在网络上看到IIS是不支持播放Flash视频,这下可槽糕了,但怎么想也想不通啊,很多视频网站基本上都采用FLASH播放,他们是怎么做到的呢。通过网上资料,最终寻找到ADOBD公司给出“Windows 2003 Server does not stream FLV videos”解决方案:(原文如下:http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19439&sliceId=1)
Please be aware that these steps do not resolve any issue with Flash, but are a configuration step for Microsoft Windows 2003 and Microsoft IIS Server 6.0. Any difficulties in executing these instructions or any errors that may arise from modifying your system settings should be addressed to Microsoft. For more details, please refer to your IIS documentation.
On the Windows 2003 server, open the Internet Information Services Manager.
Expand the Local Computer Server.
Right-click the local computer server and select Properties.
Select the MIME Types tab.
Click New and enter the following information:
Associated Extension box: .FLV
MIME Type box:flv-application/octet-stream
Click OK.
Restart the World Wide Web Publishing service.
设置好后,播放器果然可以播放了。到目前为止,可能有人会问,好像跟该文章主题“用编程方式给IIS增加MIME类型”,没有多大关系吧。好,现在就开始进入正题,既然可以手动设置IIS的MIME类型,那能不能通过程序方式自动给IIS添加MIME类型。那答案是肯定的。只要能获取到IIS控制台的MIME属性就OK了。
IIS的所有操作都可以由System.DirectoryServices来完成。同样地,MIME也应该是可以的,在MSDN中找到一篇关于“Setting MIME Type Properties Using System.DirectoryServices”文章,原文如下http://msdn2.microsoft.com/en-us/library/ms525901.aspx)关键的地方就是引用了Active DS IIS Namespace Provider。这样就得到了IISOLE.IISMimeType类。
具体代码如下:
using System; using System.IO; using System.DirectoryServices; using System.Reflection; using System.Runtime.InteropServices; using System.Collections; namespace SettingMIMEType
以上代码在WINDWOS2003 + Visual Studio 2008 + IIS 6.0环境中,测试通过。
相关文章推荐
- 用编程方式给IIS里增加MIME类型
- 用编程方式给iis里增加mime类型
- IIS如何增加处理不同的文件扩展名(MIME类型)?
- IIS增加中MIME类型xap,xaml
- [精]为IIS增加未知MIME类型文件的下载支持
- IIS增加中MIME类型xap,xaml
- (转)用编程方式给iis里增加mime类型
- Win7 在IIS中增加MIME类型文件
- [转]使用C++为IIS的虚拟目录增加MIME类型
- windows server 2003 IIS增加中MIME类型
- IIS添加mime类型
- IIS 配置 MIME类型
- IIS中的 MIME类型
- IIS 之 添加MIME扩展类型及常用的MIME类型列表
- Google KML KML 文档与MIME 类型 iis
- 让手机访问WAP网站服务器 IIS WAP服务器的MIME类型设置
- 在config配置文件添加iis的Mime类型,检测文件中是否存在添加语句,使用xml解析方法
- IIS中添加MIME类型
- Win2003 手机站IIS MIME类型设置大全
- Spring整合Mybatis(二)------增加事务管理(编程的方式)