注册后显示用户名的代码 [英] code to display username after registration

查看:74
本文介绍了注册后显示用户名的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#代码在ASP.NET中的注册页面中注册后在登录页面中显示用户名

c# code to display username in login page after registering in signup page in ASP.NET

推荐答案

User.Identity.Name ???

也许

HttpContext.Current.User.Identity.Name

取决于您的情况.

干杯!
User.Identity.Name ???

Or perhaps

HttpContext.Current.User.Identity.Name

Depends on your situation.

Cheers!




有很多方法可以做到这一点.一些开发人员遵循一种方法而另一种遵循另一种方法

一种方法是将用户名存储在会话变量中,然后在任何页面中使用该会话变量.

这里''m为会话提供链接
http://msdn.microsoft.com/en-us/library/ms178581.aspx


创建会话变量后,我们在对用户进行完全验证后在登录方法中使用该变量

让我告诉您您的要求的过程

首先是创建会话变量,请在global.asax
的会话启动事件中编写以下代码
Hi,

There are so many ways to do this .some of developer follow one method and another follow another methods

one method is storing username in session variable then use that session variable in any page.

Here ''m providing link for session
http://msdn.microsoft.com/en-us/library/ms178581.aspx


After creating session variable we use that variable in login method after complete verification of user

Let me Tell you the process of your requirement

frst step is creation of session variable write the below code in session start event in global.asax

Session.Add("UserName", "");



之后,在登录按钮中写入以下代码



After that write below code in login button

  //if user is verified as registered user
Session["UserName"]=TxtUname.Text;



之后,您可以使用以下代码在任何页面中使用该会话变量



After this you can use that session variable in any page by using following code

LblUserName.Text=Session["UserName"].Tostring();



我希望你能理解我说的话

最好的



I hope you understood What I said

All the Best


这篇关于注册后显示用户名的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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