Reputation: 107
I have the following mark-up:
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
<asp:ContentPlaceHolder ID="HeaderContent" runat="server" />
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="~/PublicPages/LogIn.css" rel="Stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div class="page">
<div id="header">
.....
and this web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
</configSections>
<system.web>
<machineKey validation="SHA1" />
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
uiCulture="de-DE"
/>
On postback, I get this error in firefox The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol and a blank page
Checking the source in IE, I see :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>
So how do I prevent asp.net from returning a page with windows-1252 charset?
Upvotes: 2
Views: 6068
Reputation: 20576
There could be a few things to check. Do you happen to have JavaScript resource loaded in your web page directly or indirectly?
If you have resource files loaded from disk are not UTF-8 encoded on other ASP.NET pages then they could be render as their default encoding. Check if any of the resource files could still be using VS encoding Windows 1252 for your JavaScript files. Saving all resources files to utf-8 type should change the setting to utf-8.
To make sure that all the ASP.NET pages have utf-8 encoding for every embedded resources, you can add the following in your every ASP.NET page:
response.codepage = 65001
response.charset = "utf-8"
Also launch FireFox in safe mode without any addon using "firefox -safe-mode" and see if that changes the behavior.
Upvotes: 0