简体   繁体   中英

Get Querystring value using c#

I am using the below code to assign the iframe src through javascript.It's working fine. But in c# code behind i got the query string like this. id=Y&amp%3bcust_id=100&amp%3 . How can i reduce this.Now

var value = "validity.aspx?id=Y&cust_id=" + cust_id + "";
frameElement.src = value

i want to get the value of customer from query string but it always return null.

if(Request.QueryString["cust_id"] !=null) //It returns null

You need to encode your "&" caracters. For some reason, the server is reading them as &amp%3b.

Try this:

var value = "validity.aspx?id=Y&cust_id=" + cust_id + "";
value = encodeURIComponent(value);
frameElement.src = value

You need to decode the URL using HttpUtility.HtmlDecode

Try something like this:

var value = HttpUtility.HtmlDecode(URL);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM