开发者

Do I need to replace localhost in the IIS://localhost/MimeMap when reading the Mimemap

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;
for开发者_开发知识库each (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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜