Asp.Net C#,在用户登录时在母版页上显示用户名. [英] Asp.Net C#, Show user's name on master page when they login.

查看:234
本文介绍了Asp.Net C#,在用户登录时在母版页上显示用户名.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是C#的新手. asp.net(3months),我正在创建一个网站,它是一家销售产品的商店的销售网站.我有一个main.master,这是我的网站设计,其中包含到login.aspx页面的图像/链接,在login.aspx页面上,我有两个用于输入登录名和密码的文本框以及一个提交按钮,即我的登录名. aspx.cs有一些代码可以与我的"Members.db"一起验证它们是否确实存在于现有客户中.但是在我的main.master上,当匿名用户登录时,我不能说"Hello Guest",而登录时却说"Hello" username"吗?我不希望有人能给我确切的答案,但是任何帮助都会像我一样现在被卡住了一段时间吗?如果您需要任何示例代码等,请询问,我将显示我所拥有的等等....
谢谢您,

Hi,
I am new to c#. asp.net(3months), I am creating a website, its a sales website for a store that sells products. I have a main.master and on this is my website design which includes an image/link to a login.aspx page, on the login.aspx page i have two text boxs for login name and password and a submit button, My login.aspx.cs has some code that verifies with my "Members.db" that they do infact exist as an existing customer. But on my main.master i cannot get it to say "Hello Guest" when anon user and "Hello ''username'' when logged in? I dont expect anyone to give me the answer exactly but any help would be great as i have been stuck on this for a while now? If you need any sample code etc please ask and i will show what i have etc....
Thank You,

推荐答案

在此处查看登录页面的设计:
传统登录页面设计讨论 [此处 [ ^ ].
对于使用登录控件构建登录页面,请查看:
如何:创建ASP.NET登录页 [ ASP.NET登录控件概述 [如何将登录,角色和配置文件系统添加到ASP.NET 2.0 [ ^ ]


现在,对于您的确切情况,如果要坚持使用它,则可以使用Session(状态管理技术之一).登录后存储登录的用户名,并在以后使用会话在需要的位置和时间显示它.
Have a look at the login page design here:
Traditional Login page design discussion[^]

Login Controls were released by Microsoft from ASP.NET 2.0, have a look at them here[^].
For, building Login Page using Login control, look:
How to: Create an ASP.NET Login Page[^]
ASP.NET Login Controls Overview[^]
How to add a Login, Roles and Profile system to an ASP.NET 2.0 [^]


Now, for your exact case, if you want to stick with it then you can use Session (one of the state management technique). Store the logged in username after login and use the session later to show it whenever and wherever needed.


您好,

创建一个会话变量,其默认字符串为"Guest"或为空.如果用户使用登录表单登录,则登录成功后将更新会话变量值.

会话将一直保留到您的应用程序运行.

希望对您有帮助,

-Amit
Hi,

Create a session variable with default string as "Guest" or empty. if user login using login form, Session variable value will be updated if login succeed.

Session will retain through out your application running.

hope this will help you,

-Amit


这篇关于Asp.Net C#,在用户登录时在母版页上显示用户名.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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