简体   繁体   中英

Request.QueryString usage to read Passed array

I'm not able to read the array passed from the other page with Request.Querystring

//Label1.Text += FID[l]; //Checked the array and it is printing properly.

Response.Redirect("show.aspx?id=" + ID + "&name=" + NAME + "&fileid=" 
                  +FID+"&length="+j);


string fid=string.Empty;
if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["fileid"].ToString())))
{
    fid = Request.QueryString["fileid"].ToString();

}

for (int l = 0; l < length; l++)
{

    Label1.Text += fid[l]; //Printing wrong array
}

Can anybody help me with this.

How can I use file to do this instead of parameter passing.文件而不是参数传递来执行此操作。

Your code makes no sense, first of all If that code is all in the same method then nothing after the Response.Redirect will run.

Second assuming the Response.Redirect is not in the same method as the other code then

if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["fileid"].ToString())))

On the above line you are calling ToString() on something that is already a string and then converting it to a string. If Request.QueryString["fileid"] is null then this will throw a null reference exception. You should do:

if (!string.IsNullOrEmpty(Request.QueryString["fileid"]))

Third fid is a string, Label1.Text is a string. Why are you looping through the string char by char and then adding them onto the end Label1.Text.

Finally fid will contain whatever is passed as the query string param "fileid", it can't contain anything else. If it has the "wrong" value then the "wrong" value is getting passed in the query string.

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