0
即时通讯使用c#在asp.net中进行测验应用程序。以下代码是我的开始页面,点击开始后我将重定向到我的问题页面。 我添加了一个start.aspx页面的唯一原因是...所以我可以初始化Session中的 值。 这里在page_load事件中,request.QueryString [“testid”]总是导致null? 即我的条件是从来没有真实的,每次我被重定向到我的“default.aspx”页面。 是什么原因?编写测验应用程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
namespace TESTPROJ2
{
public partial class START : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ArrayList a1 = new ArrayList();
Session.Add("answerlist", a1);
Session.Add("quizid", 1);
if (Request.QueryString["testid"] != null)
{
int testID = int.Parse(Request.QueryString["testid"]);
Session.Add("quizid", testID);
}
else
{
Response.Redirect("DEFAULT.aspx");
}
}
protected void startB_Click(object sender, EventArgs e)
{
Response.Redirect("QUEST.aspx");
}
}
}
你设置通过GET方法提交表单?该表单是否有名为testid的输入? – 2011-12-30 12:41:57
对我来说看起来很好,你实际请求的完整URL(带有查询字符串)是什么? – Arj 2011-12-30 12:42:09
也可以尝试测试if(Request.QueryString [“testid”] .length> 0)',它可能会返回一个空字符串。此外,请确保您的查询字符串格式正确 – Arj 2011-12-30 12:43:45