依法行政存在问题:asp.net cookie的显示问题!!急!!!

来源:百度文库 编辑:神马品牌网 时间:2024/05/04 05:21:47
我是这样
FormsAuthentication.SetAuthCookie(loginname.Text,true);
我想在其它页的特定的区域显示这个cookie也就是这个人的loginname
怎么做啊????
麻烦你指教!!!

page.user.*****加个page 如在.ascx里面引用

FormsAuthentication.SetAuthCookie是
为提供的用户名创建一个身份验证票证,并将其添加到响应的 Cookie 集合或 URL。
你是不是要实现把用户名加入到cookies里面,然后在某些位置读出来?
请说明白谢谢。
也许你是要实现下面的功能??
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

System.Web.HttpCookie hp = new HttpCookie("UserName", this.TextBox1.Text);
System.Web.HttpContext.Current.Response.Cookies.Add(hp);
this.Label1.Text = System.Web.HttpContext.Current.Response.Cookies.Get("UserName").Value;

}
}