Can I get iis7 to ignore the utf8 bom? - iis-7

Any UTF8 BOM on an included file is forwarded to the browser and ruins layout (which means any editing with notepad is impossible).
Can I learn IIS7 not to forward the BOM?

Related

My head is being rendered in the body of my wordpress site

I recently switched to a virtual host (on a windows machine) and my local alias is now example.dev
After doing this, I found that my <head> is being rendered in the body. I tried changing my file encodings to UTF-8 but that did not work.
I ended up having to change the encoding to UTF-8 for the whole project by following the answer that is here How to change encoding of all files at once with Jetbrains IDE like WebStorm

Using aspnet_regiis.exe to encrypt web.config changes euro sign to gibberish

I am using a PowerShell script to automatically encrypt certain sections of my web.config after deploying my WebApplication using Release Management. In this PowerShell script I make use of aspnet_regiis.exe to perform the encryption for me as follows:
$AspNetRegIisLocation = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe"
& $AspNetRegIisLocation -pef $configSection $configPath
With the $configSection and $configPath being correctly defined, as the encryption is working successfully. Sadly it causes the euro sign in one of the unencrypted sections to be corrupted from <sharedSettings currencyFormat="{0:€ #,##0}" /> to <sharedSettings currencyFormat="{0:€ #,##0}" />.
I have tried escaping the euro sign as € and setting the encoding="utf-8" both on and off at the top of my web.config. Neither of those solutions worked and I'm at a bit of a loss what I can do to prevent this from occurring again, apart from making the script copy all the sections prior to encrypting and reinserting the unencrypted sections afterwards.
edit: When this section is also encrypted, the displayed text on the website is also 'corrupted', which means that the solution of 'insert the unencrypted sections later' would not solve the case where the problem occurs in an encrypted section.
Turns out the issue wasn't with the use of aspnet_iisreg but in the method of reading in the web.config in my PowerShell before using it.
aspnet_iisreg requires a work-around to encrypt custom config sections if their type resides in a dll not loaded in the GAC; you need to temporarily remove or comment out the configSections element they were defined in.
Sadly I used [xml](Get-Content $webConfigLocation) to read in the web.config (which hasn't caused trouble before, which is why I mistakingly blamed aspnet_iisreg). Instead I should have used $configXml = [xml](Get-Content -Encoding UTF8 $webConfigLocation) to force it to use UTF-8 encoding.
The script would then remove the configSections element with the sections that had to be encrypted and save it, corrupting the euro sign in the process. After encrypting the configsections with aspnet_iisreg it would read the web.config again, insert the previously removed elements, and then finally save it, causing an extra iteration of corruption.
Just in case anyone ever makes a similar stupid mistake, this answer can provide them with a possible solution.

Inconsistent display of unicode characters on web pages

I have a C program that outputs some data including unicode non-English characters. It works fine in a Windows 7 command window, a Linux telnet session but used to fill a Label field on a ASP/html page it doesn't work in all situations - the platform that the web server is running on seems to affect the output.
Where I have a machine running Windows XP SP3 the program works fine in a command window but in the web page the characters are wrong. e.g. Ø is displayed as Ï.
The web page works fine where the web server is on Windows 7 and Server 2003 SP2. Web browser choice makes no difference.
The problem is probably one of character encoding.
The character encoding can be specified in each page or by setting a default value in the web server.
The Windows XP IIS probably has ISO-8859-1 as the default character set.
you can either change it by configuring IIS or by specifying the character set in each HTML page.
When Ø (U+00D8) is displayed as Ï (U+00CF), the probable explanation is that the HTML page is ISO-8859-1 or Windows-1252 encoded but the browser is interpreting it as CP 850 encoded. Check this using View → Encoding in your browser (it will show you the current encoding being applied to interpret the page, and you can change that to Windows-1252, which exists under some name (like “Western European (Windows)”) there. – There are some other encodings in which the byte 0xD8 is interpreted as Ï.
If this turns out to be the right explanation, and even if not, check the actual and declared character encoding of the page and make sure that they match. See the W3C page
Character encodings.

Unicode character not showing properly

I am working on a classic asp application hosted in IIS 6. In one asp page user enters some data and this data is e-mailed using Jmail utility.
When the user enters Swedish characters like äöü the mail does not display these characters properly. I found that setting charset in the tag will help. But it is causing me more confusions. The website is hosted on two machines and application is behaving quite differently in both the machines.
Machine 1:
If I set Charset to UTF-8 unicode characters are displayed as two characters. Browser is sending data in UTF encoding but server is decoding in ASCII.
If I set the charset to ISO-8859-1 unicode characters are displayed properly.
Machine 2:
If I set Charset to UTF-8 unicode characters are displayed properly.
If I set Charset to ISO-8859-1 unicode characters are not displayed at all.
Question:
How can I make the same code work in both places?
try to set the encoding in the 2 machine to UTF-8.
how to set encoding in iis.
copy all the files from the machine 2(That work only with UTF-8) to machine 1.
and then try.

UTF-8 server encoding results in � characters on an ASP.NET site

I am running an ASP.NET WebForms blog engine web site at maxpavlov.com
I am writing mostly in Russian on my blog. Sometimes, even though I am writing a perfectly normal Russian characters in, when I view the resulting rendered blog post page, I get some symbols substituted with �� characters.
I started digging. First, I have checked to see if a UTF-8 is set as a response encoding in the globalization section in web.config. It always was. Then I have noticed, that the pages my site generate don't have a <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> attibute provided in the page header. So I have added it to both masterpages (the display one, and the admin one - it is blogengine.net's specific stuff).
Now all pages that the web server generates have the charset value set to UTF-8, but the problem remains.
The site, when I create a blog post saves it to XML file, that also has an encoding set at the top of the XML file to UTF-8 with the following line:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
Still, problem characters appear in the browsers, when I go to my site.
Where else should I fix this encoding problem?
More info: Fiddler tells me that the response header Content-Type: text/html; charset=utf-8
What is interesting, is that in different browsers, different characters in the HTTP Response get substituted with a �.
By the way, if anyone still wonders what the thing is - it's IIS Native RewriteModule. It's buggy even in version 2, if you disable it for the site, the problem goes away. Tried to report it in IIS.net - didn't believe me. Just learned to live without it on web sites that need to display a cyrillic characters.
Try using Windows-1251 (cyrillic) encoding for the russian alphabet.

Resources