Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从HttpContext.Current.Session[";PaTSUA";]中获取包含值列表的特定值?_C#_Httpcontext - Fatal编程技术网

C# 如何从HttpContext.Current.Session[";PaTSUA";]中获取包含值列表的特定值?

C# 如何从HttpContext.Current.Session[";PaTSUA";]中获取包含值列表的特定值?,c#,httpcontext,C#,Httpcontext,我想从会话变量中选择一个特定值。如何从本次会议中获得该值 var tz = HttpContext.Current.Session["PaUA"]; 这是我正在使用的代码。当我在即时窗口中执行时,它会显示如下结果 {PS.UserInterface.Models.UA} ApplicationID: {de151484-f822-4692-a36b-e7e1fc1066fe} CompanyID: {fef3fb8e-365f-4cc4-8976-ff9e5ed1516c} DBConnect

我想从会话变量中选择一个特定值。如何从本次会议中获得该值

var tz = HttpContext.Current.Session["PaUA"];
这是我正在使用的代码。当我在即时窗口中执行时,它会显示如下结果

{PS.UserInterface.Models.UA}
ApplicationID: {de151484-f822-4692-a36b-e7e1fc1066fe}
CompanyID: {fef3fb8e-365f-4cc4-8976-ff9e5ed1516c}
DBConnectionString: "Data Source=WIN-ISPHTIHPJFI\\MSSQLSERVER2016;Initial Catalog=PSDefault;User ID=dba;Password=dba@2018"
DefaultModuleID: {00000000-0000-0000-0000-000000000000}
IsMainContractor: true
LicenseID: {ac258d7d-25dc-44f9-b798-2d4657d68c95}
LicenseType: "MultiUser"
LoginName: "suvaneeth"
LoginTime: "11-Apr-2019 18:39:34"
RolesCSV: "SAAdmin"
ThemeCode: "Liquid"
TimeZone: "Dateline Standard Time"
UserID: {fc938df0-8a4e-4c85-b93c-be51373c559f}
UserName: "Suvaneeth S"
UserProfileID: {fc938df0-8a4e-4c85-b93c-be51373c559f}
UserWeekStartDay: "1"
licenseModuleCSV: "830683B5-6D12-4AF9-AF76-7013A930AA0D,F774DF88-C2D6-4527-8A0E-493E1E1D3120"

但是我不知道如何从这个结果中得到时区最简单的方法是这样做:

 static void Main(string[] args)
    { 
        var test = new test { abc = "asdasdasd" };
        var xx = (dynamic)test;
        Console.WriteLine(xx.abc);
    }

    class test
    {
        public string abc { get; set; }
    }
所以对你来说:

var tz = HttpContext.Current.Session["PaUA"];
var xx = (dynamic)tz;
var zone = tz.TimeZone;

刚投到UA级就好了

var tz = (PS.UserInterface.Models.UA)HttpContext.Current.Session["PaUA"];
var timezoneValue= tz.TimeZone;

那个对象类型名称是什么?对不起,我不明白?@MuratCanOĞUZHAN我想从这个会话中选择时区,比如
(HttpContext.Current.Session[“PaUA”]as PS.UserInterface.Models.UA)。时区
?你可以使用cast将它转换为动态,然后在我的项目的DataAccessLayer中使用这个会话来获取属性值im。因此,在那里创建一个属性是可行的?@dhanilDinesan如果您经常使用它,您可以存储它,但在DataAccessLayer中,我无法访问UserInterface,对吗?将会话值作为参数传递给方法,不要在dataaccesslayer@dhanildinesan中使用会话。如果我在dataaccesslayer中使用会话,是否存在任何安全问题或类似问题?没有安全问题。但不要在会议中保留个人信息。例如,若您想在会话中保留密码,那个么当您想在后端对密码进行解密时,您应该保留加密版本的密码。