我试图运行下面的脚本的用户的用户名:获得谁登录
这里LoginName1
是System.Web.UI.WebControls.LoginName
。 LoginName1
在网页上显示用户名就好了。 但它似乎没有工作。我哪里错了?
下面是完整的代码[最新]:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site1.master" AutoEventWireup="true"
CodeBehind="~/Default.aspx.cs" Inherits="memberlogin.Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script runat="server" >
public void redirect()
{// I have removed previous content - it JUST WONT REDIRECT THE PAGE
//String loginame = System.Web.HttpContext.Current.User.Identity.Name;
//if (loginame == "usertest")
Response.Redirect("Default.aspx");
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" >
<h1>
<span class="input">Welcome to the members-only page.</span>
</h1>
<h2>
Start Client Side Application.
</h2>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<span class="input"> You are not logged in. Click the Login link to sign in</span>
</AnonymousTemplate>
<LoggedInTemplate>
<span class="input">You are logged in. Welcome, </span>
</LoggedInTemplate>
</asp:LoginView>
<asp:LoginName ID="LoginName1" runat="server" />
<table class="style1">
<tr>
<td align="center" valign="middle">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Click on This Image Link To Start The Application<br />
<br />
<asp:ImageButton OnClick="click" runat="server" ID="ImageButton1" Height="100px"
ImageUrl="~/Images/loader.jpg" PostBackUrl="~/Loading.aspx" />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</td>
</tr>
</table>
<asp:LoginStatus ID="LoginStatus1" runat="server"
LogoutAction="Redirect" BackColor="White"
Font-Underline="True" LogoutPageUrl="~/Default.aspx" />
</asp:Content>
它怎么样? – 2012-03-08 18:24:59
当我将光标移动到'LoginName1'时,它说“这个成员定义了多次。 – 2012-03-08 18:46:30
你在哪里调用重定向? – RQDQ 2012-03-08 19:29:52