Reputation: 20803
I have an ASP.NET site that was working fine running on Windows Server 2003 / IIS6.
I moved it to Windows Server 2008 / IIS7 and the aspx page output now includes gibberish text.
For example:
p����
�����
The majority of the page renders properly, but there is gibberish here and there. I have checked the event logs and there is nothing.
Any idea what's going on here? How can I fix this?
I have noticed that this issue shows up when I include multiple Server.Execute statements in the aspx code:
<% Server.Execute("/inc/top.inc"); %>
<% Server.Execute("/inc/footer.inc"); %>
The .inc files above contain just html. It appears that the files have to be of a significant length to cause the error. Here is the sample html I've been testing with:
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
Also, the gibberish characters appear inconsistently. If I ctrl+F5 the pages, the gibberish characters change and occasionally don't appear at all.
Upvotes: 5
Views: 7914
Reputation: 44776
I would bet the problem is that what you're seeing is the regular error page, gzip-compressed. However, the gzip compression HTTP header got lost when the server was redirected to the error page, so the browser doesn't know to uncompress it. Do you have some custom module that is doing compression? Are you setting the Response.Filter?
Upvotes: 2
Reputation: 20803
We could never get this resolved.
The only solution that worked was to eliminate use of Server.Execute().
Upvotes: 1
Reputation: 1315
In the Windows Event Viewer you most probably will be able to find the real cause of the error. That way you can fix it.
Unfortunately you require RPD / physical access to the server, and it's only solving the error. Not the cause of the error not appearing.
Upvotes: -1
Reputation: 512
this has nothing to do with encoding. This is IIS not knowing how to handle error messages if you are using it in combination with a virtual directory. My guess is that if you run this site in local debug on a machine, the error messages show up fine. Try that, if so, then you can start to infer where the actual error is.
Upvotes: 1
Reputation: 46423
Pop in to Firefox and try manually switching the page encoding (maybe to Windows-1252 first), see if the gibberish clears up. If it's suddenly readable, then at least you will know it's an encoding problem.
I'd also suggest looking at the output in a hex editor to see what you're actually getting. That could also give you a clue where to look. Might also try turning off gzip encoding or page compression.
Upvotes: 1
Reputation: 9668
Also you can check globalization element in web.config
It must be in system.web section:
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="utf-8"
responseHeaderEncoding="utf-8"
/>
Upvotes: 1
Reputation: 46673
http://forums.asp.net/p/329153/330330.aspx contains a discussion of a similar issue, I wonder if it's the same problem you're seeing. Here's an excerpt from rox.scott's answer:
if you are transfering execution of the page after Response.Type, etc., is set then the resulting Response will have the Response.Type and encoding set by the initial page -- which might not be compatible with characters on the second page. solution: make sure you are correctly specifying Response type and encoding on BOTH pages.
Want to try this and see if it works?
If that doesn't work, http://msdn.microsoft.com/en-us/library/39d1w2xf.aspx has an interesting discussion of various configuration options you can try to force consistent encodings throughout your site. You may want to try some of those. Also, that MSDN article does not use the ContentType directive but instead recommends this:
<%@ Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %>
Not sure if that will generate equivalent results as adjusting ContentType, but it's easy enough to try.
Upvotes: 1
Reputation: 887385
You are probably sending a different encoding than the encoding of the .inc
files.
Check the encodings of your .aspx
and .inc
files, and check the charset
parameter of the content-type
header being sent to the browser.
EDIT: Since the server is sending UTF-8, you should convert your .inc
files to UTF-8.
To do that, open the file in Visual Studio, click File, Advanced Save Options, and select Unicode (UTF-8 without signature) - Codepage 65001
. (Near the bottom of the list)
Upvotes: 0
Reputation: 916
This is a bit of a stab, but try setting your pipeline mode to "classic" in IIS.
Upvotes: 0
Reputation: 40497
Try setting charset parameter.
<% Page ContentType="text/html; charset=utf-8"%>
Upvotes: 0