What is the impact of encoding on post data from ASP pages to Asp.net pages?
I talked to people about this on a BBS. Although it is very simple, I think there are still issues that many people have not noticed. I will post them for reference, the same should be true for post on HTML pages.
Yovav : Do u think it's possible that codePage is "lost" when posting data from ASP to an ASP. NET page?
SAMUEL: to your question"Do u think it's possible that codePage is" lost "when posting data from ASP to an ASP. NET page? "
, I think it's not possible ---
It's really truth.
When posting data from ASP to ASP. NET page, the codePage will automatically be changed into UTF-8.
Therefor, you 'd better set your ASP. NET page's codePage/charset correctly.
Yovav: How can I traslate this to ASP. NET (or at least define the codePage )?
<% @ CodePage = "1252" %>
<%
Session. codePage = 1252 'impant ant: syncronize with the server code page
Response. charset = "UTF-8" 'important: Make the server respond with correct charset
%>
Thanks again.
My form is now posting correctly-thanks to you
SAMUEL: From your code, I found that you want dynamic codePage/charset for response. Is it?
For dynamic response in ASP. NET, put the follow code inPage_load ()
Event of. CS/. VB file:
Session. codePage = 1252
Response. charset = "UTF-8 ";
For static response, modify. aspx file like this:
<% @ Page Language = "C #" codebehind = "aspnetpage1.aspx. cs" autoeventwireup = "false"
Inherits = "aspposttoasp. net. webform1"CodePage = "1252"
%>
...
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
If you used session and response object to set codePage/charset, the defined value in. aspx file will be invalid.
It seems that codePage of UTF-8 is 65001 against 1252 in ASP. NET.
Yovav: I thought I shoshould do it like this,
So the only solution for me is to use your great two conversion functions
Great job! -I'm sure that a lot of people don't have a clue how to deal with this problem...