Question

I'm reading out the mime types from IIS's MimeMap using the command

_mimeTypes = new Dictionary<string, string>();
//load from iis store.

DirectoryEntry Path = new DirectoryEntry("IIS://localhost/MimeMap");
PropertyValueCollection PropValues = Path.Properties["MimeMap"];

IISOle.MimeMap MimeTypeObj;
foreach (var item in PropValues)
{
    // IISOle -> Add reference to Active DS IIS Namespace provider
    MimeTypeObj = (IISOle.MimeMap)item;
    _mimeTypes.Add(MimeTypeObj.Extension, MimeTypeObj.MimeType);
}

Do I need replace the localhost part when I deploy it to my live server? If not, why not and what are the implications of not doing so.

Cheers

Was it helpful?

Solution

It should not be an issue to leave the host as 'localhost'.

After all, you want to get the MimeMap of the machine your app is running on, correct?

A possible complication that I can forsee is that if you are using a third party as a host. They can do anything they want with host headers and it may be possible that localhost is not available for whatever reason.

But you should simply give it a shot and adjust if necessary.

OTHER TIPS

If you leave it like 'Localhost', you will have to run this script directly on the server.

If you change it to fetch the machine name directly, you can think of running this script remotely as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top