成员资格api登录用户,用户ID问题 [英] membership api login user ,user id problem

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

问题描述

大家好,


我正在使用成员资格api,希望获取登录用户userid,但始终不成功.
我正在使用以下代码.

Guid UserID1 =新的Guid(Membership.GetUser( User.Identity.Name ).ProviderUserKey.ToString());

User.Identity.Name 始终返回null或空字符串.

还想知道如何检查每个页面上的表单身份验证.如果用户未登录,则重定向到登录页面,并在成功登录后使用forms.authencation重定向到同一页面.

请解决我的这个问题......


问候
Bilal

Hi All,


I am using membership api,looking to get the logon user userid but always unsuccessful.
I am using the following code.

Guid UserID1 = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

User.Identity.Name always return null or empty string.

also want to know how to check on each page forms authentication.if user is not login it redirect to login page and after successful login redirect to same page using forms.authencation...

Please solve this problem of mine......


Regards
Bilal

推荐答案

还想知道如何检查每个页面上的表单身份验证.如果用户未登录,则重定向到登录页面,并在成功登录后重定向到使用forms.authencation的同一页面...
如果您具有表单身份验证,则无需执行任何操作.表单身份验证实现会自动进行处理.如果用户未通过身份验证并登录,则他们将被自动定向到登录页面(如Web.Config文件中的Forms身份验证标签中所定义)

User.Identity.Name始终返回null或空字符串.
用户通过身份验证后,请尝试此操作.可能是您在用户未登录时尝试使用它.
also want to know how to check on each page forms authentication.if user is not login it redirect to login page and after successful login redirect to same page using forms.authencation...
If you have Forms Authentication in place then you don''t need to do anything. Forms Authentication implementation automatically takes care of it. If the user is not authenticated and logged in then they will be automatically directed to login page (as defined in Forms authentication tag in Web.Config file)

User.Identity.Name always return null or empty string.
Try this once user is authenticated. Might be you are trying it when the user is not logged in.


没有合法的方法可以从成员资格表中获取用户ID.
U可以使用loginview控件来维护整个页面的用户名.
there is no legal way to get userID from membership tables.
U can use loginview control to maintain username all through pages.


这篇关于成员资格api登录用户,用户ID问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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