Wrong encoding reading form fields

N

Nelson R.

Hi,

im using a form to get some input from the user. This form is in a
HTML file.

When I post the form directly to my email, i receive all fields
correctly. Example test.html:
<FORM action="MAILTO:[email protected]" method=post
enctype="text/plain">

But if I post the form to an aspx page and try to read the fields
value, i get the wrong encoding content. Example

test.html:
<FORM action="test.aspx" method=post>

test.aspx
for(int i=0 ; i<Request.Form.Count; i++)
Response.Write(Request.Form.Keys+"="+Request.Form);

This will print all fields and values, but without any portuguese
characters.

So, anyone knows were i must define the encoding to solve this
problem? ive tried putting in metatag in test.html page, tried putting
in page directive in test.aspx page. Nothing works.

Wich encoding is responsible form Request.Form values?


Thanks,
Nelson R.
 
T

Torben Philippsen

Nelson R. said:
for(int i=0 ; i<Request.Form.Count; i++)
Response.Write(Request.Form.Keys+"="+Request.Form);

This will print all fields and values, but without any portuguese
characters.


Hi!

I have had a similar problem with danish characters. I solved the problem by
using the HtmlEncode method.
You only have to encode the strings you send to the server (your aspx page)
and the server will automaticly decode the string.

If you look the HtmlEcode method up in the documentation I am certain, that
you will find a solution to your problem.

Best regards
Torben
 
N

Nelson R.

Hi Torben,
thanks for your response.

I understand the use of Server.HtmlEncode when encoding an URL
parameters.
But in my situation, I have an HTML page with a form posting to an
ASPX page. I can only use server code when reading form fields in ASPX
page.

When posting directly to an email, the characters are correct, but
when posting to an ASPX page all portuguese chars are gone... so I
supose the problem is in the ASPX page, that should be using the
correct encoding for reading posted form fields...

Any ideas?

Nelson R.




Nelson R. said:
for(int i=0 ; i<Request.Form.Count; i++)
Response.Write(Request.Form.Keys+"="+Request.Form);

This will print all fields and values, but without any portuguese
characters.


Hi!

I have had a similar problem with danish characters. I solved the problem by
using the HtmlEncode method.
You only have to encode the strings you send to the server (your aspx page)
and the server will automaticly decode the string.

If you look the HtmlEcode method up in the documentation I am certain, that
you will find a solution to your problem.

Best regards
Torben
 
N

Nelson R.

Hi,

solved my problem. Needed to change encoding in webconfig to:

<globalization requestEncoding="windows-1252"
responseEncoding="windows-1252" />


Now its working.


Nelson R.





Hi Torben,
thanks for your response.

I understand the use of Server.HtmlEncode when encoding an URL
parameters.
But in my situation, I have an HTML page with a form posting to an
ASPX page. I can only use server code when reading form fields in ASPX
page.

When posting directly to an email, the characters are correct, but
when posting to an ASPX page all portuguese chars are gone... so I
supose the problem is in the ASPX page, that should be using the
correct encoding for reading posted form fields...

Any ideas?

Nelson R.




Nelson R. said:
for(int i=0 ; i<Request.Form.Count; i++)
Response.Write(Request.Form.Keys+"="+Request.Form);

This will print all fields and values, but without any portuguese
characters.


Hi!

I have had a similar problem with danish characters. I solved the problem by
using the HtmlEncode method.
You only have to encode the strings you send to the server (your aspx page)
and the server will automaticly decode the string.

If you look the HtmlEcode method up in the documentation I am certain, that
you will find a solution to your problem.

Best regards
Torben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top