Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Request.QueryString用于读取传递的数组_C#_Asp.net_Arrays_Parameter Passing - Fatal编程技术网

C# Request.QueryString用于读取传递的数组

C# Request.QueryString用于读取传递的数组,c#,asp.net,arrays,parameter-passing,C#,Asp.net,Arrays,Parameter Passing,我无法读取通过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=strin

我无法读取通过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
}
//Label1.Text+=FID[l]//已检查阵列,并且正在正确打印。
Response.Redirect(“show.aspx?id=“+id+”&name=“+name+”&fileid=”
+FID+“&长度=”+j);
字符串fid=string.Empty;
如果(!string.IsNullOrEmpty(Convert.ToString(Request.QueryString[“fileid”].ToString()))
{
fid=Request.QueryString[“fileid”].ToString();
}
对于(int l=0;l
有人能帮我吗


如何使用Global.aspx文件来执行此操作,而不是传递参数

您的代码毫无意义,首先,如果该代码都在同一个方法中,那么响应后将不会有任何内容。重定向将运行

其次,假设Response.Redirect与其他代码不在同一个方法中

if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["fileid"].ToString())))
在上面的一行中,您正在对已经是字符串的内容调用ToString(),然后将其转换为字符串。如果Request.QueryString[“fileid”]为null,则会引发null引用异常。你应该做:

if (!string.IsNullOrEmpty(Request.QueryString["fileid"]))
第三个fid是一个字符串,Label1。文本是一个字符串。为什么要一个字符一个字符地循环字符串,然后将它们添加到结束标签1.Text上


最后,fid将包含作为查询字符串param“fileid”传递的任何内容,它不能包含任何其他内容。如果它有“错误”值,则在查询字符串中传递“错误”值。

for循环之前的fid值是多少?您能告诉我如何在Response.Redirect中传递数组吗?您不能将数组传递到查询字符串中,但如果它是字符串数组,您可以执行
string MyString=string.Join(“,”,MyArray);
将其转换为单个字符串,每个元素用逗号分隔。然后,您可以在另一端将其转换回数组,类似于
string[]MyArray=MyString.Split(',')为什么不把上面的评论添加到你的答案中,我会把它标记为正确答案。