Reputation: 1319
I am trying send html elements via http post. How safely encode and decode html string? HtmlEncode doesn't help, because it doesn't encode & and it looks as new parameter.
Upvotes: 1
Views: 2198
Reputation: 25803
You need to encode the same way you would encode a query string.
string myPostVars = string.Format(
"myHtml={0}&myInt={1}",
HttpUtility.UrlEncode("<div>This is my div</div>"),
90210
);
Upvotes: 1
Reputation: 3774
The safest way to pass anything via POST is to convert it into base64. Try this.
Upvotes: 1
Reputation: 1796
You probably want to URLEncode not HTMLEncode
http://msdn.microsoft.com/en-us/library/zttxte6w.aspx
Upvotes: 1