首先我添加了一个Web 用户控件,并添加一个HeadLink图片,代码如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeadLink.ascx.cs" Inherits="HeadLink" %>
<asp:ImageMap ID="ImageMap1" runat="server" ImageUrl="~/Image/HeadLink.jpg" 
    Width="800px">
    <asp:RectangleHotSpot Bottom="30" Left="0" NavigateUrl="system.aspx" Right="159" />
    <asp:RectangleHotSpot Bottom="30" Left="160" NavigateUrl="tsxx.aspx" Right="319" />
    <asp:RectangleHotSpot Bottom="30" Left="320" NavigateUrl="yuanxiAdmin.aspx" Right="479" />
    <asp:RectangleHotSpot Bottom="30" Left="480" NavigateUrl="banjiAdmin.aspx" Right="639" />
    <asp:RectangleHotSpot Bottom="30" Left="640" NavigateUrl="Login.aspx" Right="799" /></asp:ImageMap>
红色部分的字体我是想点击“退出系统”时,跳转到刚开始时候的登录页面Login页面,并且在一个母版MasterPage中用到了该Web用户控件。。
在运行Login登陆页面后我使用某个用户名、密码和身份登录到main_Ok页面,并且mian_OK页面使用了masterPage母版,但是在点击“退出系统”时,总是会跳转到main_OK页面,请问大家这是什么原因呢?
Login页面判断用户身份的代码如下:
protected void Page_Load(object sender, EventArgs e)
    {        if (Session["leave"] != null)
        {
            string leave = Session["leave"].ToString();            if (leave == "1")
            {
                Response.Redirect("tsxx.aspx");
            }            else
            {
                Response.Redirect("main_OK.aspx");
            }
        }
    }

解决方案 »

  1.   

    是不是因为没有使用Session.Clear();这一句话????
    在使用Button按钮时可以加上这句话,但是我是用的是Web 用户控件添加的图片,这样该怎样清除回话呢???
      

  2.   

    Session["leave"] 没清除--------------  protected void Page_Load(object sender, EventArgs e)
            {            if (Session["leave"]!=null)
                {
                    Response.Redirect("后台主页.aspx");
                }
                else
                {
                    Response.Redirect("登陆框页面.aspx");
                }            
            }        /// <summary>
            /// 退出事件中加入此方法
            /// </summary>
            protected void LoginOut()
            {
                Session.Remove("leave");
                Response.Redirect("登陆框页面.aspx");
            }
      

  3.   

    LZ再推出登陆的时候把session清楚掉,
    如果还是不行再用断点调试程序试试
      

  4.   

    在退出系统时清空Session,然后再登陆进来的页面判断一下,如果Session==null Response.Redirect  Login.aspx,否则 main_ok