获取登录用户的StudentID [英] Get StudentID of logged in user

查看:117
本文介绍了获取登录用户的StudentID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hellow,我有一个场景,每个登录的学生都有一个StudentId,我必须得到studentId,以便我可以使用它来添加新记录,问题是我可以使用下面的代码返回给我当前登录的用户的名字。我不知道如何获取登录用户的studentId。这是我想要做的但我被困住了,有人可以指导我,因为每个用户都有UserId,所以我必须通过userId获取studentId





Hellow ,I have a scenario whereby each logged in student Has a StudentId,i have to get the studentId so as i can use it to add a new record,The issue is i can use the code below which returns to me the name of the user currently logged.I dont know how to get the studentId of that logged in user.This is how i am trying to do but am stuck,Can someone guide me as each user has a UserId,So i have to pass the userId to get the studentId


MembershipUser user = Membership.GetUser(Page.User.Identity.Name);



如果我通过它这种格式它会添加一条记录,但我不想这样做,只是我如何从登录用户中获取


If i pass it this format it adds a record but i dont want to do it this way,just how i can get it from the logged in user

int studentId=21;

推荐答案

这解决了它



MembershipUser user = Membership.GetUser(Page。 User.Identity.Name);

Guid id = new Guid(user.ProviderUserKey.ToString());



int studentId = Students.GetstudentId(id);
This solved It

MembershipUser user = Membership.GetUser(Page.User.Identity.Name);
Guid id = new Guid(user.ProviderUserKey.ToString());

int studentId =Students.GetstudentId(id);


这篇关于获取登录用户的StudentID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆