1

I have a hiddenfield in which i am storing storing the user input and code generated value in string format. Since the string may contain the hyperlink etc i used HTmlEncode before putting it into a hidden field and used to decode the value when i am retrieving from the hiddenfield. If the user input contain French characters then the code will crash. How to encode a string containg- links,french and other culture characters. I am getting the below error

A potentially dangerous Request.Form value was detected from the client (ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$EmailHiddenField="...434] - [Exécuter la macro...").
Manoj Nayak
  • 2,449
  • 9
  • 31
  • 53
  • Please add code to your question and error/exception you are getting when "code will crash". (Or whoever upvoted the question can do the same instead). – Alexei Levenkov Apr 12 '13 at 05:10

2 Answers2

3

Well.. If you are using c# then here is my try..

Encode the whole HTML document to Base64 string and then use URLEncode.

byte[] bytesToEncode = Encoding.UTF8.GetBytes(myHTMLDocAsString);
string encodedText = Convert.ToBase64String(bytesToEncode);

and then URLEncode(encodedText)

This could be successfully transfered over HTTP as POST without errors!

Now in case you required to store it in hidden field then instead of POSTing, just enter it into the hidden field..

Hope it helps..

Hiren Pandya
  • 989
  • 1
  • 7
  • 20
2

Use globalization tag as:

<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="nb-no" uiCulture="no"/>

Further follow this answer you will come to know encode-decode of these strings:

Getting U+fffd/65533 instead of special character from Query String

Community
  • 1
  • 1
Freelancer
  • 9,008
  • 7
  • 42
  • 81