查询字符串问题 [英] query string problem
本文介绍了查询字符串问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么查询字符串中的最后一个参数忽略了空格?
如何保留它。
Why The last parameter in the query string is ignoring the space?
How to retain it.
string str = "Default2.aspx?test=1 &JobId=1 ";
Response.Redirect(str);
当我转到Default2.aspx页面时,我将获得testas 1后跟三个空格
但是JobId只有1,即没有任何空格。
When i move to Default2.aspx page, i will obtain "test" as 1 followed by three spaces
but JobId as 1 only i.e with out any space.
推荐答案
你必须使用 HttpUtility.UrlEncode() [ ^ ]以获得您对 querystring 的期望。
只需按以下步骤操作。
You have to use HttpUtility.UrlEncode()[^] to get what you expect in querystring.
Just do as below.
string str = "Default2.aspx?test=" + HttpUtility.UrlEncode("1 ") + "&JobId=" + HttpUtility.UrlEncode("1 ");
Response.Redirect(str);
谢谢......
Thanks...
这篇关于查询字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文