我想在登录成功后将登录页面的用户名显示在受尊重的重定向页面上。

问题描述:

我想在登录成功后将登录页面的用户名显示在受尊重的重定向页面上。为此,我在重定向页面上取了一个标签,显示用户名sholud。

I want to display the username of Login Page on to the respected redirect page after successful login.For this i had taken one label on redirected page on which the username sholud be get displayed.

您可以在成功登录后在会话中存储UserName,并在所有页面中使用它。

在显示部分,您也可以使用MasterPage,这意味着您不要不必在每个单独的页面中使用标签/文字。
You can store the UserName in Session after successful Login and use it across in all the Pages.
And on the displaying part you may use MasterPage also, which means you don't have to use Label/Literals in each Individual Pages.


验证用户名之后重定向到另一个页面保留上下文中的用户名



即Context.Items.Add(UserName,你的用户名);



用txtUsername.Text替换你的用户名。



重定向页面



In!isPostBack



lblUserName.text = Context.Items [UserName]。toString();
After Validating the Username Before redirecting to another Page keep username in Context

i.e Context.Items.Add("UserName","YOur User Name");

Replace Your User Name With txtUsername.Text.

In Redirected Page

In !isPostBack

lblUserName.text=Context.Items["UserName"].toString();


读取和探索: ASP.NET Web应用程序中的页面和应用程序上下文 [ ^ ]