My “stuff to blog about” well has pretty much run dry, as anyone who follows this blog knows. Fortunately there’s always a customer running into something that I’ve never thought about something to inspire me. Bad for the poor customer hitting the issue, but good for the rest of us.
A customer wasn’t able to make ASP pages from CE Web Server work when the pages were UTF-8. The same page had worked fine as ANSI. The error they got was when setting <% Response.Expires = -1 %> in their page.
The HTTP headers are already written to the client. HTTP header
modifications must be made before writing page content
ASP scripting compilation error: ‘80020009’
In file: /Test/default.asp
On line: 1
ASP aficionados, can you guess what was happening?
What happens is UTF-8 puts special characters in the first bytes of a file indicating to an editor that it is UTF-8. When our ASP interpreter parses out a page, it sees those UTF-8 characters and (unfortunately) doesn’t know about UTF-8 and assumes its ASP body that needs to be sent out. Once ASP body has been sent, you’re not allowed to send HTTP headers anymore, which is why the Expires=-1 wasn’t working.
I had the customer remove the special bytes and also look into the Response.Charset() to make sure the browser knew the encoding of the file (always a good idea with non-ANSI anyway).