C# 用户1登录后退出时出现奇怪问题。然后用户2登录,可以看到用户1的名称和信息

C# 用户1登录后退出时出现奇怪问题。然后用户2登录,可以看到用户1的名称和信息,c#,asp.net,winforms,internet-explorer,active-directory,C#,Asp.net,Winforms,Internet Explorer,Active Directory,我有一个很奇怪的问题,我想不出来。我甚至不知道它是怎么发生的。这只发生在IE10中(还没有尝试过其他版本的IE)。这在Firefox、Chrome、Opera或Safari中不会发生。当用户1登录到该网站时,他们也可以看到他们所属的商店。如果有10家商店,他们只能访问4家,那么他们只能在下拉列表中看到这4家商店。下拉列表是动态的,从SQLServer表接收值。如果用户1注销,它们将被发送到一个注销页面,该页面将放弃会话,在用户退出表单身份验证后签名,然后将其重定向回登录页面。现在,用户2登录。它

我有一个很奇怪的问题,我想不出来。我甚至不知道它是怎么发生的。这只发生在IE10中(还没有尝试过其他版本的IE)。这在Firefox、Chrome、Opera或Safari中不会发生。当用户1登录到该网站时,他们也可以看到他们所属的商店。如果有10家商店,他们只能访问4家,那么他们只能在下拉列表中看到这4家商店。下拉列表是动态的,从SQLServer表接收值。如果用户1注销,它们将被发送到一个注销页面,该页面将放弃会话,在用户退出表单身份验证后签名,然后将其重定向回登录页面。现在,用户2登录。它进入“仪表板”,显示用户2已登录。当用户2导航到特定页面时,用户2的用户名变成用户1的用户名,然后用户2现在可以看到用户1所属的所有商店。离开此页面,将显示用户2的信息。导航回该特定页面,用户1返回。正如我以前说过的,我不确定发生了什么事。我甚至不知道该给你看什么代码。我会假设,如果这是一个编码问题,它将在我的页面加载在该特定页面上。这是那个网络表单的页面负载

代码隐藏

protected void Page_Load(object sender, EventArgs e)
    {
        conn.Open();

        //This selects the user's ID where the user name equals the user that is currently logged in. 
        SqlCommand cmdUserID = new SqlCommand("SELECT UserID from Users WHERE UserName = '" + User.Identity.Name + "'", conn);
        selectUserID = Convert.ToString(cmdUserID.ExecuteScalar());

        //Selections the location ID where the userID is equal the the UserName.
        SqlCommand cmdLocationID = new SqlCommand("SELECT LocationID from UserControl WHERE UserID = '" + selectUserID + "'ORDER BY LocationID ASC", conn);
        selectLocationID = Convert.ToString(cmdLocationID.ExecuteScalar());

        //Selects the Coporate or Store where the userID is equal to the UserName.
        SqlCommand cmdCorporateStore = new SqlCommand("SELECT MAX(CorporateStore) from Users WHERE UserID = '" + selectUserID + "'", conn);
        selectCorporateStore = Convert.ToString(cmdCorporateStore.ExecuteScalar());

        //Selects if the user is an Admin.
        SqlCommand cmdAdmin = new SqlCommand("SELECT MAX(Admin) from Users WHERE UserID = '" + selectUserID + "'", conn);
        selectAdmin = Convert.ToString(cmdAdmin.ExecuteScalar());

        conn.Close();

        //use to display "Garage" when an admin logs in.
        if (selectAdmin == "Yes")
        {
            Control allUsers = this.Page.Master.FindControl("login").FindControl("loginview").FindControl("ulmenu").FindControl("allUsers");
            allUsers.Visible = true;
        }

        gvVehicleTEMP.ControlStyle.Font.Size = 8;

        if (!IsPostBack)
        {
            ddlDealershipRec.Items.Clear();
            List<string> locationList = new List<string>();
            List<int> locationIDList = new List<int>();

            conn.Open();

            //used to populate the dropDownList depending who is logged in. 
            using (SqlDataReader reader = cmdLocationID.ExecuteReader())
            {
                while (reader.Read())
                {
                    int locationID = reader.GetInt32(0);
                    locationIDList.Add(locationID);
                }
                conn.Close();
            }

            foreach (int id in locationIDList)
            {
                conn.Open();
                SqlCommand cmdLocation = new SqlCommand("SELECT LocationName FROM Location WHERE LocationID = '" + id + "' ORDER BY LocationName ASC", conn);
                using (SqlDataReader reader = cmdLocation.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string location = reader.GetString(0);
                        locationList.Add(location);
                    }
                    conn.Close();
                }
            }

            foreach (string location in locationList)
            {
                ddlDealershipRec.Items.Add(new ListItem(location));
            }
            if (Session["Search"] != null)
            {
                if (gvVehicleTEMP.Rows.Count == 0)
                {
                    gvVehicleTEMP.Visible = true;
                    gvVehicleBOUNCE.Visible = false;
                    string Search = (string)(Session["Search"]);
                    string Option = (string)(Session["Option"]);
                    string Dealership = (string)(Session["Dealership"]);

                    ddlDealershipRec.SelectedValue = Dealership;
                    ddlSearchOptions.SelectedValue = Option;
                    tbSearch.Text = Search;

                    conn.Open();

                    if (ddlSearchOptions.Text == "Stock #")
                    {
                        DataTable dt = new DataTable();
                        SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM VehicleTEMP WHERE (Dealership LIKE  '%" + Dealership + "%') AND StockNumber = '" + Search + "'", conn);
                        da.Fill(dt);
                        gvVehicleTEMP.DataSource = dt;
                        gvVehicleTEMP.DataBind();

                        conn.Close();
                        Session.Clear();

                    }
                    else if (ddlSearchOptions.Text == "Deal #")
                    {

                        DataTable dt = new DataTable();
                        SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM VehicleTEMP WHERE (Dealership LIKE  '%" + Dealership + "%') AND FIMAST = '" + Search + "'", conn);
                        da.Fill(dt);
                        gvVehicleTEMP.DataSource = dt;
                        gvVehicleTEMP.DataBind();

                        conn.Close();
                        Session.Clear();
                    }

                    if (selectCorporateStore == "Store")
                    {
                        foreach (GridViewRow row in gvVehicleTEMP.Rows)
                        {
                            gvVehicleTEMP.FooterRow.Visible = false;
                            gvVehicleTEMP.Columns[16].Visible = false;
                            gvVehicleTEMP.Columns[17].Visible = false;
                            gvVehicleTEMP.Columns[20].Visible = false;
                            gvVehicleTEMP.Columns[21].Visible = false;
                            gvVehicleTEMP.Columns[22].Visible = false;
                            gvVehicleTEMP.Columns[23].Visible = false;
                            gvVehicleTEMP.Columns[26].Visible = false;

                            ((TextBox)row.FindControl("tbStockNumber")).Enabled = false;
                            ((DropDownList)row.FindControl("ddlLocation")).Enabled = false;
                            ((TextBox)row.FindControl("tbGrossProfit")).Enabled = false;
                            ((TextBox)row.FindControl("tbReason")).Enabled = false;
                            ((TextBox)row.FindControl("tbFunded")).Enabled = false;
                            ((TextBox)row.FindControl("tbTitled")).Enabled = false;
                        }
                    }
                    else if (selectCorporateStore == "Corporate")
                    {
                        foreach (GridViewRow row in gvVehicleTEMP.Rows)
                        {
                            btnTopUpdate.Visible = true;
                            gvVehicleTEMP.Columns[4].Visible = false;
                            gvVehicleTEMP.FooterRow.Visible = true;
                            ((TextBox)row.FindControl("tbStockNumber")).Enabled = true;
                            ((DropDownList)row.FindControl("ddlLocation")).Enabled = true;
                            ((TextBox)row.FindControl("tbGrossProfit")).Enabled = true;
                            ((TextBox)row.FindControl("tbReason")).Enabled = true;
                            ((TextBox)row.FindControl("tbFunded")).Enabled = true;
                            ((TextBox)row.FindControl("tbTitled")).Enabled = true;
                        }
                    }
                }
            }
        }
    }
受保护的无效页面加载(对象发送方,事件参数e)
{
conn.Open();
//这将选择用户名等于当前登录用户的用户ID。
SqlCommand cmdUserID=new SqlCommand(“从UserName='”+User.Identity.Name+'”,conn的用户中选择UserID);
selectUserID=Convert.ToString(cmdUserID.ExecuteScalar());
//选择用户ID与用户名相等的位置ID。
SqlCommand cmdLocationID=新的SqlCommand(“从UserControl中选择LocationID,其中UserID='”+selectUserID+“'ORDER BY LocationID ASC”,conn);
selectLocationID=Convert.ToString(cmdLocationID.ExecuteScalar());
//选择用户ID等于用户名的公司或商店。
SqlCommand cmdCorporateStore=new-SqlCommand(“从UserID='“+selectUserID+'”,conn的用户中选择MAX(CorporateStore));
选择CorporateTore=Convert.ToString(cmdCorporateTore.ExecuteScalar());
//选择用户是否为管理员。
SqlCommand cmdAdmin=new SqlCommand(“从UserID='“+selectUserID+'”,conn的用户中选择MAX(Admin));
选择admin=Convert.ToString(cmdAdmin.ExecuteScalar());
康涅狄格州关闭();
//用于在管理员登录时显示“车库”。
如果(选择Admin==“是”)
{
Control allUsers=this.Page.Master.FindControl(“登录”).FindControl(“登录视图”).FindControl(“ulmenu”).FindControl(“allUsers”);
诱惑者。可见=真实;
}
gvVehicleTEMP.ControlStyle.Font.Size=8;
如果(!IsPostBack)
{
ddleDealershipRec.Items.Clear();
List locationList=新列表();
List locationIDList=新列表();
conn.Open();
//用于填充dropDownList,具体取决于登录的用户。
使用(SqlDataReader=cmdLocationID.ExecuteReader())
{
while(reader.Read())
{
int locationID=reader.GetInt32(0);
locationIDList.Add(locationID);
}
康涅狄格州关闭();
}
foreach(locationIDList中的int id)
{
conn.Open();
SqlCommand cmdLocation=new SqlCommand(“从LocationID=”“+id+”“按LocationName ASC排序”的位置中选择LocationName”,conn);
使用(SqlDataReader=cmdLocation.ExecuteReader())
{
while(reader.Read())
{
字符串位置=reader.GetString(0);
位置列表。添加(位置);
}
康涅狄格州关闭();
}
}
foreach(locationList中的字符串位置)
{
添加(新列表项(位置));
}
如果(会话[“搜索”]!=null)
{
如果(gvVehicleTEMP.Rows.Count==0)
{
gvVehicleTEMP.Visible=真;
gvVehicleBOUNCE.Visible=假;
字符串搜索=(字符串)(会话[“搜索]);
字符串选项=(字符串)(会话[“选项]);
字符串经销商=(字符串)(会话[“经销商]);
DDL经销商Rec.SelectedValue=经销商;
ddlSearchOptions.SelectedValue=选项;
tbSearch.Text=搜索;
conn.Open();
如果(ddlSearchOptions.Text==“股票#”)
{
DataTable dt=新的DataTable();
SqlDataAdapter da=新SqlDataAdapter(“从VehicleTEMP中选择*,其中(经销商类型“%”+经销商+“%”)和StockNumber=“+Search+”,conn”);
da.填充(dt);
gvVehicleTEMP.DataSource=dt;
gvVehicleTEMP.DataBind();
康涅狄格州关闭();
Session.Clear();
}
else if(ddlSearchOptions.Text==“交易#”)
{
DataTable dt=新的DataTable();
SqlDataAdapter da=新SqlDataAdapter(“从VehicleTEMP中选择*,其中(经销商类似“%”+经销商+“%”),而FIMAST=“+Search+”,conn”);
da.填充(dt);
gvVehicleTEMP.DataSource=dt;
GV车辆
//Ie 8 and lower have an issue with the "Cache-Control no-cache" and "Cache-Control store-cache" headers.
//The work around is allowing private caching only but immediately expire it.
if ((Request.Browser.Browser.ToLower() == "ie") && (Request.Browser.MajorVersion < 9))
{
     context.Response.Cache.SetCacheability(HttpCacheability.Private);
     context.Response.Cache.SetMaxAge(TimeSpan.FromMilliseconds(1));
}
else
{
     context.Response.Cache.SetCacheability(HttpCacheability.NoCache);//IE set to not cache
     context.Response.Cache.SetNoStore();//Firefox/Chrome not to cache
     context.Response.Cache.SetExpires(DateTime.UtcNow); //for safe measure expire it immediately
}
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);