1 无效的指针
就是这句话 Response.Write("<script language='javascript'>alert('请先登陆');location.href='login.aspx';</script>");
在我的机子上运行得好好的,一移植到服务器上就不出原来的那个的效果了,,而且在状态栏上显示出现无效的指针2 一个页面中需要多次从Session["student_id"]中取值 我把他放到一个静态字符中,结果混乱得不成样子了,好像是大家公用了这个静态字 串了 一个用户登陆后所有人的页面上的Session["student_id"]都变成最后这个登陆的人了
就是这句话 Response.Write("<script language='javascript'>alert('请先登陆');location.href='login.aspx';</script>");
在我的机子上运行得好好的,一移植到服务器上就不出原来的那个的效果了,,而且在状态栏上显示出现无效的指针2 一个页面中需要多次从Session["student_id"]中取值 我把他放到一个静态字符中,结果混乱得不成样子了,好像是大家公用了这个静态字 串了 一个用户登陆后所有人的页面上的Session["student_id"]都变成最后这个登陆的人了
2.觉得不太可能。session并不是谁都可以改变的,你这个session的值是不是和公共变量的同名?就是application("变量名")这样定义的变量
我用我的帐号登陆,而写进数据库的是别人的记录
改用ViewState[]试下!
这个student_id是全局的三
告诉大家呀
static string student_id = Session["student_id"].ToString();
这种student_id是全局的,,类似的 application我们几个人做过实验了
测试代码,,用登陆的人的IP判断
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace gxk
{
/// <summary>
/// temp 的摘要说明。
/// </summary>
public class temp : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
static string AAA="";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
bind();
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text=AAA;
}
private void bind()
{
if(Request.ServerVariables["HTTP_VIA"]!=null)
{
AAA=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
AAA=Request.ServerVariables["REMOTE_ADDR"].ToString();
}
}
}
}