[2005] Porbably an encoding problem
Hi all,
I don't know if my problem is .NET related, SQL Server related or windows related. But I know it's Microsoft related (not blaming or pointing fingers).
Here is my problem:
I have an ASP.NET website running under IIS 6 (Windows 2003) using .NET 2.0 and an SQL Server 2005 DB.
For some reason sometimes the special characters such as ., @ ... show up as %2E, %40... etc and I can't find out why.
Any help is really appreciated
Re: [2005] Porbably an encoding problem
Show up where? IN your database, or on your webpage?
Re: [2005] Porbably an encoding problem
Quote:
Originally Posted by nemaroller
Show up where? IN your database, or on your webpage?
On web pages, and specifically when auto filling text boxes
Re: [2005] Porbably an encoding problem
Sounds like you're specifically encoding text and assigning it to a server control in a manner that invokes it to html encode its input - resulting in a double-encoded string. Or probably more disturbing, you have html-encoded data in your database. A simply query of the tables will allow you to make sure.
Try a find search for :
".Text = HttpUtility.HtmlEncode"
Note that certain server controls html encode by default depending on certain properties that are set.
Re: [2005] Porbably an encoding problem
That'd be correct if I was always getting the html code for special characters. but the disturbing thing is this only happens sometimes. Most of the time I get the data correctly.
And to be specific I have 1 DB server, 2 different (windows 2003) hosting servers.
Could this be system settings on one of the servers? Is there a way to find out?
Re: [2005] Porbably an encoding problem
So on the same page, with the same exact data, sometimes the characters are encoded and sometimes they are not? So you're suspicious of a configuration difference between the two 2k3 web servers?
Re: [2005] Porbably an encoding problem
Start by... comparing the machine.configs on both machines. Use something like windiff. I don't know if that should make a difference though. But try it anyways.
Re: [2005] Porbably an encoding problem
Quote:
Originally Posted by nemaroller
So on the same page, with the same exact data, sometimes the characters are encoded and sometimes they are not? So you're suspicious of a configuration difference between the two 2k3 web servers?
Yes
Quote:
Originally Posted by mendhak
Start by... comparing the machine.configs on both machines. Use something like windiff. I don't know if that should make a difference though. But try it anyways.
I'll try that tomorrow, I hope it works
Re: [2005] Porbably an encoding problem
Of course it won't. Don't be so optimistic.
Also, I know it's a little anal, but can you post a screenshot of similar scenarios where it's working and where it isn't? Also, when it starts showing weird characters, can you get the HTML source of that rendered page and put it up here, probably in a .txt file.