如何从会话中获取对象属性

 我要公道2602932023 发布于 2023-02-11 05:34

我的asp.net C#项目中有一个名为"admin"的类.
它是:

public class Admin
{  
    private int ID;
    private string FirstName, LastName, IsMainAdmin, Email, Username, 
            Password,BirthDate, EntryDate;  

    public int id
    {
        get { return ID; }
        set { ID = value; }
    }

    public string firstname
    {
        get { return FirstName; }
        set { FirstName = value; }
}

    public string lastname
    {
        get { return LastName; }
        set { LastName = value; }
    }
    .  
    .  
    .  

登录后会创建一个会话,如下所示:

Admin admin = isAdmin(username, password);
    if (admin != null)
    {
        **Session.Add("maskanAdmin", admin);**
        Response.Redirect("panel.aspx");
    }

在其他页面中,我需要通过jquery ajax在页面请求之后的代码后面的会话中获取管理员的ID.
请注意,我在Method后面的代码是[WebMethod],它不支持Session Object.
我能得到它吗?怎么样?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有