共用方式為


IIsMimeType.MimeType (ADSI)

The MimeType method gets or sets a string indicating a MIME type, for example, "text/xml". Also use Extension to set the file name extension that is mapped to this MIME type.

objIIsMimeType.MimeType = <MIME type>

Code Example

<%  
Dim MimeMapObj 
Dim MimeMapList 
Const ADS_PROPERTY_UPDATE = 2 
Dim NewMimeMapSize 

' Use GetEx to retrieve the MimeMap Array 
Set MimeMapObj = GetObject("IIS://localhost/MimeMap") 
MimeMapList = MimeMapObj.GetEx("MimeMap") 

' Create a new item in the array 
NewMimeMapSize = UBound(MimeMapList) + 1  
Redim preserve MimeMapList (NewMimeMapSize) 

' Create our new MimeType item 
Set MimeMapList(NewMimeMapSize) = CreateObject("MimeMap")  
MimeMapList(NewMimeMapSize).Extension = ".log"  
MimeMapList(NewMimeMapSize).MimeType = "text/plain"  

' Use PutEx to UPDATE the MimeMap array with our new array 
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapList 
MimeMapObj.SetInfo  
%> 

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

See Also

Concepts

IISMimeType

IIsMimeType (ADSI)

IIsMimeMap (ADSI)

Using ADSI to Configure IIS