How to request authentication in an Asp.net menu item

Asked

Viewed 78 times

2

I have the login form that is currently being used to enter the system, but I need to do this authentication also by clicking on a particular menu item. I need that when clicking on "Home", ask for this authentication again, and if the user has permission enter, if not enter. How do I do that ?

Masterpage:

<asp:Menu ID="Menu" runat="server" style="margin-bottom: 0" BackColor="White" 
            DynamicHorizontalOffset="2" Font-Names="Arial" Font-Overline="False" 
            Font-Size="Medium" Font-Strikeout="False" Font-Underline="False" 
            ForeColor="#7C6F57" StaticSubMenuIndent="10px" RenderingMode="List" OnMenuItemDataBound="NavigationMenu_MenuItemDataBound">
            <DynamicHoverStyle BackColor="#B2223D" ForeColor="White" />
            <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="5px" ForeColor="White" />
            <DynamicMenuStyle BackColor="#5D7B9D"  ForeColor="White" />
            <DynamicSelectedStyle BackColor="#FF0066" ForeColor="White"/>
            <Items>
    asp:MenuItem NavigateUrl="~/Index.aspx" Text="Home" Value="Home"></asp:MenuItem>
</Items>
            <StaticHoverStyle BackColor="#68655C" ForeColor="White" />
            <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="5px"  />
            <StaticSelectedStyle BackColor="#B2223D" ForeColor="White" />
        </asp:Menu>
  • What code . Cs you have so far?

  • @Paulohdsousa Nothing, I erased everything.

  • The user is already authenticated, you want him to log in again by accessing the menu?

1 answer

1


If you want to use the same system input authentication, you could force a logout using FormsAuthentication.SignOut(); when it clicked on the "Home" menu and redirected it to an authentication URL, like this: Response.Redirect("~/Login.aspx?ReturnUrl=%2fIndex.aspx");. This would require you to authenticate again and redirect you to the "Home page"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.