2
我尝试添加会话,然后我另一个页面上访问重定向后,这始终显示为空重定向到另一个页面时,会话始终为空? C#
Session.Add("pUser_Name", ds_1.Tables[0].Rows[0]["User_Name"].ToString());
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Redirect("DashBoard.aspx", false);
这里另一页上我正在访问这样
protected void Page_Load(object sender, EventArgs e)
{
if (Session["pUser_Name"] == null) ////here is error NULL
{
Response.Redirect("Admin.aspx");
}
}
我试图
protected override void OnInit(EventArgs e)
{
if (Session["pUser_Name"] == null)
{
Response.Redirect("Admin.aspx");
}
base.OnInit(e);
}
还有
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DashBoard.aspx.cs" Inherits="SC.DashBoard" EnableTheming="true"
Theme="Theme1" EnableSessionState="True" %>
和管理页面,价值分配到会话
<%@ Page Language="C#" AutoEventWireup="true" EnableSessionState="True" CodeBehind="Admin.aspx.cs" Inherits="SC.Admin" %>
和web.config文件
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<sessionState timeout="12000"/>
</system.web>
,但仍面临着相同的会话是空
只是一个尝试,而不是'Session.Add'使用'HttpContext.Current.Session.Add'和访问像'HttpContext.Current.Session [“pUser_Name”]' –
同样的问题仍然没有解决 –
更新面板也没有解决问题.. –