开发者

Why does HTML data transforms after Response.Redirect()?

I'm using Session开发者_JAVA技巧 to pass data from one page to another. The data contains HTML and when I display it in the other page, I see that it's different.

This is how I put data in Session:

Session["omschrijving"] = Server.UrlEncode(lblOmschrijving.Text);

This is how I get data from Session:

ftbOmschrijving.Text = (string)Session["omschrijving"];

Can someone help me please? Thank you in advance.


you need to decode encoded data.

· HttpUtility.UrlEncode() - to encode data

· HttpUtility.UrlDecode () - to decode data


Well since you UrlEncode your data you need to decode it when reading.

ftbOmschrijving.Text = Server.UrlDecode(Session["omschrijving"]);


Simply do this

Session["omschrijving"] = lblOmschrijving.Text;

and the same to retrieve

ftbOmschrijving.Text = Convert.ToString(Session["omschrijving"]);


As far as I am concerned, you don't even need to URL encode that data, since you are putting it in a Session variable. It is an unnecessary process, which takes valuable processor time.

UrlEncoding is used when you put the String value in an Url, i.e. if you would Redirect to a certain url.

Drop the UrlEncode(), and UrlDecode() and you should still be fine, and have saved a little time in page load, and caused a little less frustration for those poor low bandwidth surfers !


I would try:

ftbOmschrijving.Text = Server.UrlDecode(Session["omschrijving"]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜