当您使用唯一 ID 为您的个人资料页面获取数据时,您可以遵循以下可能的解决方案:
登录时,将您的唯一 ID 保存在会话变量中 -
Session["myID"]= "your id fetched from database";
当您单击另一个人的图像的超链接时,使用查询字符串概念将该用户的唯一 ID 附加到 url。
Response.Redirect("profile.aspx?ID="userID"); //the userID will be the user's uniqueID.
当您从菜单中单击配置文件页面时,附加会话值:
Response.Redirect("profile.aspx?ID=Session["myID"].toString());
然后在页面加载中profile.aspx
你可以这样做:
private void Page_Load(object sender, System.EventArgs e)
{
string receivedID = Request.QueryString["ID"].toString();
if(receivedID == Session["myID"].toString())
{
//this is yourself, so fetch your data from DB
}
else
{
//fetch the data of the receivedID passed in querystring(URL)
}
}