Microsoft KB Archive/835385

= Certain characters disappear when you receive data that you pass by using the POST request from an ASP Web page or from an HTML Web page =

Article ID: 835385

Article Last Modified on 5/18/2007

-

APPLIES TO


 * Microsoft ASP.NET 1.1
 * Microsoft ASP.NET 1.0

-



SYMPTOMS
In a Microsoft ASP.NET Web form, when you receive data that you pass by using the POST request from an Active Server Pages (ASP) Web page or from an HTML Web page, certain characters may disappear. For example, if you pass BeginãøåöäéEnd from an ASP Web page or from an HTML Web page, in the ASP.NET Web form, you may receive only BeginEnd.



CAUSE
HMTL Web pages, ASP Web pages, and ASP.NET Web forms use character sets to represent characters. When you pass data to an ASP.NET Web form, if the data is in the format of a character set that the Web form uses, the Web form can receive the data. However, if the ASP Web page or the HTML Web page that sends the data uses a different character set than the character set that the Web form uses, the behavior that is mentioned in the &quot;Symptoms&quot; section of this article occurs.



RESOLUTION
To resolve this problem, use one of the following methods. If you do not know the character set that your Web page uses, Microsoft recommends that you change the character set that the Web page uses.

Change the character set that the Web page uses
Change the character set that the Web page uses to the character set that the Web form uses. To do this, follow these steps:  In the Web.config file of your ASP.NET Web Application project, locate the   element. Note the value for the requestEncoding attribute of the   element.  In your ASP Web page or in your HTML Web page, locate the following code: PageTitle Note  is a placeholder for the title of your Web page.   Add the following code after the code that you located in the previous step.

Note In the following code, replace  with the value that you noted in step 1.  

Change the character set that the Web form uses
Change the character set that the Web form uses to the character set that the Web page uses. To do this, follow these steps:
 * 1) Note the character set that the Web page uses. If you do not know the character set that the Web page uses, locate the META element for the Web page, and then note the value for the charset property of the associated CONTENT attribute.

Note The META element is an optional element. Therefore, your Web page may not contain a META element. In such a scenario, this resolution may not resolve the problem.
 * 1) In the Web.config file of your ASP.NET Web Application project, locate the   element.
 * 2) Change the values for the requestEncoding attribute and the responseEncoding attribute to the value that you noted in step 1. If you did not note any value in step 1, change the values for the requestEncoding attribute and the responseEncoding attribute to typical values (such as &quot;ISO-8859-1&quot; and &quot;Windows-1252&quot;).



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Start Microsoft Visual Studio .NET.</li> Use Microsoft Visual Basic .NET to create an ASP.NET Web Application project. By default, the WebForm1.aspx file is created.</li> Add a Label control to the WebForm1 Web form.</li>  Add the following code to the Page_Load event handler for the WebForm1 Web form: Label1.Text = Request.Form(&quot;postdata&quot;) </li> Add an HTML Web page to the project.</li> In Solution Explorer, right-click the Web page that you added in the previous step, and then click Set As Start Page.</li>  In the HTML View of the Web page, add the following code to the BODY element: <form action=&quot;WebForm1.aspx&quot; method=&quot;post&quot; ID=&quot;Form1&quot;> <input type=&quot;text&quot; name=&quot;postdata&quot; ID=&quot;Text1&quot;> <input type=&quot;submit&quot; value=&quot;Post&quot; ID=&quot;Submit1&quot; NAME=&quot;Submit1&quot;> </li> Build the project.</li> In Solution Explorer, right-click the Web page, and then click View in Browser.</li> In the text box, type the following text:

BeginãøåöäéEnd </li> Click Post.</li> The WebForm1 Web form appears with the following text:

<pre class="fixed_text">BeginEnd

Notice that certain characters have disappeared.</li></ol>

<div class="references_section">