Re: How to set content-type header for ASP/HTML pages only ?

From: David Wang [Msft] (someone_at_online.microsoft.com)
Date: 02/20/04


Date: Fri, 20 Feb 2004 08:27:56 -0800

MIME Type can be set on a per-URL basis all the way to global.

Global MIME Type changes require IIS Web Server restart (about a 5-10 second
process) to take effect. Other per-URL settings take effect immediately.

Reason I want a restart of IIS is because when you change IIS configuration
while running, it is *possible* that it is NEVER saved -- so if your server
crashes, upon restart, you will find all your prior settings just missing
(it's like making changes in Word, never saving, and then Word crashes --
you lose all the non-saved changes).

Restarting IIS forces a flush of the in-memory configuration changes to disk
(in effect, a "save"), and if anything crashes... you'll know sooner rather
than later who the culprit is. You can trigger the flush without restarting
IIS by writing a script on the commandline which uses IIS's administration
API, but usually, it's easier for people to understand restarting IIS
instead of telling them how to write scripts.

-- 
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"Alan Silver" <alan-silver@nospam.thanx> wrote in message
news:Yg39tWDoANNAFwCs@nospamthankyou.spam...
In article <eiCANjm9DHA.632@TK2MSFTNGP12.phx.gbl>, "David Wang [Msft]"
<someone@online.microsoft.com> writes
>Character encoding, per the HTTP 1.1 spec on W3C, is a part of Content-Type
>(what is transmitted over the wire is
>Content-Encoding(Content-Type(data)) ).  IIS supports this feature via MIME
>Map, which sets Content-Type on a per-extension basis (including "all"
>extensions).
>
>Thus, you should configuration the MIME Map setting on IIS (it's right
below
>where you set Custom HTTP response headers).  It can be set to take effect
>globally unless you override it with another MIME Map setting.  You will
>have to restart IIS for the changes to take effect (you don't have to, but
>I'm having you to it to be safe for other reasons).
>
>If you do not wish to use built in functionality exposed via the UI, feel
>free to write your own custom ISAPI Filter to implement your desired
>functionality.
>
>BTW: I just set the MIME Map for .html to "text/html; charset=ISO-8859-1"
at
>the per website level, and instantly, only requests to .html on that
website
>returned  "Content-Type: text/html; charset=ISO-8859-1".  It seems like
it's
>what you were looking for.
David,
Thanx very much, that explains it fine. I just tried it on a test server
here and it seems to be OK. I didn't realise that you could add the
encoding in with the content type.
Just out of interest, why do you say the server should be restarted "for
other reasons" ? I don't really want to restart the production server
more than I have to as it is accessed 24x7.
Thanx again
>--
>//David
>IIS
>This posting is provided "AS IS" with no warranties, and confers no rights.
>//
>"Alan Silver" <alan-silver@nospam.thanx> wrote in message
>news:sZ+gzgEJJlMAFwvV@nospamthankyou.spam...
>In article <ebV#DPO9DHA.2404@TK2MSFTNGP11.phx.gbl>, "David Wang [Msft]"
><someone@online.microsoft.com> writes
>>The right way to do this association is with a MIME-Type (IIS can
configure
>>this on a per-URL level, meaning you can even make SOME ASP pages return
>>custom values but not others, depending on URL scope), which allows you to
>>set the value of the Content-Type header on a per-extension basis.  This
>>requires restarting IIS for it to take effect.
>>
>>What you were doing was setting headers that IIS sends on all requests,
>>which is valid for other uses, just not for Content-Type.
>
>Thanx for the reply.
>
>I thought that MIME types were only for setting the content type. I want
>to set the character encoding. I was doing it via a Content-Type header
>as that was a) the way suggested by the W3C and b) 'cos I didn't know
>any other way to do it for the whole server.
>
>Do you know how to set the character encoding for all ASP/HTML pages
>served ? TIA
>
>>"Alan Silver" <alan-silver@nospam.thanx> wrote in message
>>news:TwL$pdLdJPMAFwLh@nospamthankyou.spam...
>>Hello,
>>
>>I would like to set the content-type HTTP header for Content-Type. I
>>tried adding the header :-
>>
>>Content-Type: text/html; charset=ISO-8859-1
>>
>>as recommended by the W3C, but this sends this header for *all* files
>>served, not just ASP and HTML. For example, it sends the header for CSS
>>files, which causes the validators to choke.
>>
>>Is there any way to set the Content-Type specific to file type ? I
>>searched Google, but didn't find anything on this. It seems strange to
>>be able to set a global Content-Type, but not be able to associate it
>>with a file type.
>>
>>TIA
>>
>>P.S. I am using IIS4 on NT4 Server if it makes any difference.
>>
>
-- 
Alan Silver


Relevant Pages

  • Re: Internal Server Error (500) - The data is invalid (IIS/6)
    ... the most simple HTML probably generated by the web server ... HTTP/1.1 500 Internal Server Error ... This includes IIS restart or server restart. ...
    (microsoft.public.inetserver.iis)
  • Re: Error 401.1 (iis 6.0)
    ... Getting 401.1 indicates that the username/password provided to IIS was ... IIS6 should never need to restart -- just recycling the Application Pool ... I would look at the hang ... Try using IIS State when the server appears hanging and post the log here. ...
    (microsoft.public.inetserver.iis)
  • Re: IIS Stopped Occasionally
    ... I'm suspecting you're describing that IIS stopped, and you can't restart IIS ... machine (i.e. "restart the server"). ... clue to you that something is still hanging onto a port 80 that IIS wants to ...
    (microsoft.public.inetserver.iis.security)
  • Re: Cantt download "exe" file because of IIS version
    ... MIME Type controls) can be sent on a response: ... If IIS sent it via the static file handler, ... static file handler working to send the download (and the rest of my earlier ... I performed a hunt in the registry in both the problematic server and the ...
    (microsoft.public.inetserver.iis)
  • Cant download files from SBS 2007 IIS Site
    ... Im running SBS 2007 with a single nic and updates enabled. ... When I do this from the server ... Its easy to add a mime type, ... delete webconfig.xml and allow IIS to create a new one by simply doing ...
    (microsoft.public.windows.server.sbs)

Loading