使用profile访问profile数据时,用户显示为在线.GetProfile ASP.Net



我有一个gridview与我的用户列表(使用ASP。网络会员和配置文件提供程序),我已经设法显示我需要的所有字段。但问题是,当我访问编辑用户配置文件的页面或我向gridview添加一列时,它显示了用户配置文件的一些字段,这些都被设置为登录。

为什么会这样?这种情况可以避免吗?

我需要知道用户的列表,以及目前真正登录的用户,但由于这个问题,我无法知道,因为所有用户都标记为登录。

这是我的网格视图的代码。

   <asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserName"
   OnRowCreated="gvUsers_RowCreated" OnRowDeleting="gvUsers_RowDeleting" 
            Font-Size="8pt" Width="700px" CellPadding="4" ForeColor="#333333" 
            GridLines="None" AllowSorting="true">
       <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
   <Columns>
      <asp:BoundField HeaderText="Usuario" DataField="UserName"/>
      <asp:HyperLinkField HeaderText="E-mail" DataTextField="Email"
         DataNavigateUrlFormatString="mailto:{0}" DataNavigateUrlFields="Email" />
      <asp:TemplateField HeaderText="No. Cliente">
        <ItemTemplate>
           <asp:Label ID="lblCustormerID" runat="server" Text='<%# Profile.GetProfile(Eval("UserName").ToString()).Contacts.CustomerID %>'></asp:Label>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField HeaderText="Creado" DataField="CreationDate"
         DataFormatString="{0:MM/dd/yy h:mm tt}" />
      <asp:BoundField HeaderText="Ultima Actividad" DataField="LastActivityDate"
         DataFormatString="{0:MM/dd/yy h:mm tt}" />
      <asp:CheckBoxField HeaderText="Activo" DataField="IsApproved"
         HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
       </asp:CheckBoxField>
      <asp:CheckBoxField HeaderText="En Línea" DataField="IsOnline"
         HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
       </asp:CheckBoxField>
      <asp:HyperLinkField Text="<img src='../images/edit.gif' border='0' />"
         DataNavigateUrlFormatString="EditUsers.aspx?UserName={0}"
         DataNavigateUrlFields="UserName" />
      <asp:ButtonField CommandName="Delete" ButtonType="Image"
         ImageUrl="~/images/delete.gif" />
   </Columns>
       <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
       <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
   <EmptyDataTemplate>No se encontraron usuarios.</EmptyDataTemplate>
       <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
       <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
       <EditRowStyle BackColor="#999999" />
       <AlternatingRowStyle BackColor="White" />
</asp:GridView>

我花了几个小时在谷歌上搜索答案,没有任何运气,所以非常感谢你的帮助。

提前感谢!

我最近在我的一个应用程序上实现了一个类似的系统,该系统使用Windows身份验证,可以在这里工作。

我有一个叫做ActiveUser的类,它有字段UserID, UrlRequested和daterrequested,还有一个叫做ActiveSession的类,它有一个List(Of ActiveUser)。它还有静态方法AddUser(删除列表中与UserID匹配的任何现有项,然后添加一个新项)和GetUsers(删除DateRequested超过10分钟的任何人)。

然后在Application_Start下的Global.asax文件中设置ActiveSession类。在Application_BeginRequest中,我将用户添加到列表中。然后你可以从GetUsers绑定列表到你想要的任何页面。

最新更新