Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6528987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:35:12+00:00 2026-05-25T09:35:12+00:00

Not sure if this is possible but here we go: Our MVC website has

  • 0

Not sure if this is possible but here we go:

Our MVC website has currently been redesigned. Previously, we had the had the Logon button as an image, and if the user was authenticated, a logout button would be displayed. Like so:

<%
    if (Request.IsAuthenticated)
    {
%>
<a href="/Account/LogOff">
    <img src="/images/logout.png" alt="logout" border="0" />
</a>
<%
    }
    else
    {
%>
<a href="<%: Url.Action("LogOn","Account")%>">
    <img src="/Images/login.png" alt="Log On" border="0" />
</a>
<%
    }
%>

The way the website has been designed however, the login button is now incorporated in the navigation menu. As we have multiple areas within the site, we use a c# method class from within a Helper class to generate the menus from the sitemap, like so:

public static string TabbedMenu(this HtmlHelper html, string area)
{
    // Get all the current information.
    //
    RouteData route = html.ViewContext.RequestContext.RouteData;
    string controller = route.GetRequiredString("controller");
    string action = route.GetRequiredString("action");

    StringBuilder menuWrapper = new StringBuilder();
    menuWrapper.Append("<ul id=\"main-nav\" class=\"nav fl\">");

    // Using the sitemap, build a tabbed menu.
    //
    foreach (SiteMapNode node in SiteMap.RootNode.ChildNodes)
    {
        if (node.Title == area)
        {
            foreach (SiteMapNode node2 in node.ChildNodes)
            {
                if (node2["controller"].ToLower() == controller.ToLower())
                {
                    menuWrapper.Append("<li class=\"menu-item current-menu-item\">");
                }
                else
                {
                    menuWrapper.Append("<li class=\"menu-item\">");
                }

                RouteValueDictionary values = new RouteValueDictionary(new { Action = node2["action"], Controller = node2["controller"], Area = node2["area"] });
                VirtualPathData vpd = RouteTable.Routes.GetVirtualPathForArea(html.ViewContext.RequestContext, values);
                string target = vpd.VirtualPath;

                menuWrapper.AppendFormat("<a href=\"{0}\">{1}</a>", target, node2.Title);

                menuWrapper.Append("</li>");
            }
            break;
        }
    }


    menuWrapper.Append("<li id=\"menu-item-143\" class=\"login menu-item menu-item-type-custom menu-item-object-custom menu-item-143\"><a href=\"#\">Login</a></li>");
    menuWrapper.Append("<li id=\"menu-item-333\" class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-333\"><a href=\"#\">Sign up</a></li>");

    menuWrapper.Append("</ul>");

    return menuWrapper.ToString();
}

So my question really is, is there any way to authenticate the user from within this helper method?

Any help would be appreciated,

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:35:12+00:00Added an answer on May 25, 2026 at 9:35 am

    Can you add new parameter to that function:

    public static string TabbedMenu(this HtmlHelper html, string area, bool IsAuthenticated)
    {
         ...
         if(IsAuthenticated)
             print something...
         else
             print something else...
         ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if this is even possible but here goes: Currently I have
I know this is possible but I'm not really sure where to start. Has
I'm not sure if this is possible, but here's what I would like to
I'm not sure if this is even remotely possible but here it goes: is
Not sure if this is possible, but here goes. I have a MongoDB (using
I am not sure if this is possible but here is my situation. Say
Not sure if this is possible but here is what I would like to
I'm not sure if this is even possible but here we go. I have
I'm not sure this is even possible, but here goes: I have a class
I'm not sure if this is possible or not, but here's roughly what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.