我用c#做了一个页面,有个登陆窗口,在各个窗口之间传递值用session,刚开始没有用session传值时,速度很正常,但后来发现用了session后,速度非常慢,无法接受!不是电脑问题!问了同事后,他们说session不会影响速度!
现在调试了半天,找不出毛病,请哪位高人指点指点!我qq是809893057,可以加我!
现在调试了半天,找不出毛病,请哪位高人指点指点!我qq是809893057,可以加我!
调试欢乐多
namespace User_Part
{
public partial class _Default : System.Web.UI.Page
{
XmlDocument MyDoc = new XmlDocument();
protected void Page_Load(object sender, EventArgs e)
{
Session.RemoveAll();
MyDoc.Load(HttpContext.Current.Server.MapPath("UserList.xml"));
}
protected void BtOk_Click(object sender, EventArgs e)
{
//检索xml判断用户名与密码是否正确
//并根据用户级进入不同的页面
System.Xml.XmlNodeList nodes = MyDoc.SelectNodes("//user");
if (nodes != null)
{
foreach (System.Xml.XmlNode xn in nodes)
{
if (xn.SelectSingleNode("name").InnerText == UserText.Text)
{
if (xn.SelectSingleNode("passwd").InnerText == PassText.Text)
{
if (xn.SelectSingleNode("level").InnerText == "admin")
{
Session.Add("level","admin");
Session.Add("username",UserText.Text);
Response.Redirect("verify.aspx");
}
if (xn.SelectSingleNode("level").InnerText == "user")
{
Session.Add("level","user");
Session.Add("username", UserText.Text);
Response.Redirect("FileUpload.aspx");
}
}
else
{
Response.Write("<script>window.alert('密码错误!');window.location='Login.aspx'</script>");
}
}
}
Response.Write("<script>window.alert('无效用户名!');window.location='Login.aspx'</script>");
}
MyDoc.Save(HttpContext.Current.Server.MapPath("UserList.xml"));
}
}
}
string level = Request.QueryString["level"].ToString();
这个安全性不是很好@!直接在地址栏中输入url就能进入页面
要不你再试试把user、level合成一个字符串存入一个Session,中间拿个|标记分开
调用的时候分割字符串用试试