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 6252623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:50:16+00:00 2026-05-24T13:50:16+00:00

Im having an issue with areas and generating links from them. Here’s the rough

  • 0

Im having an issue with areas and generating links from them. Here’s the rough structure of the code Im working with:

Home
   Area1
     Area 1 Content
   Area2
     Area 2 Content
   Area3
     Area 3 Content

In my _layout.cshtml file I generate a menu (which is completely table driven):

foreach (MainMenu mm in parentMenus)
{
    List<SubMenu> theseChildren = childMenus.Where(o => o.MainMenuId == mm.MainMenuId).OrderBy(p => p.Ordering).ToList();

    result.Append(String.Format(@"<h3><a href='#'>{0}</a></h3>", mm.Name));
    result.Append(String.Format(@"<div>"));
    result.Append(String.Format(@"<p>"));
    foreach(SubMenu sm in theseChildren){

        //Issue is here:

        result.Append(String.Format(@"<a href='{0}/{1}/{2}'>{3}</a> <br />", sm.AreaName == null ? String.Empty : sm.AreaName, sm.ControllerName, sm.ActionName, sm.Name));
    }
    result.Append(String.Format(@"</p>"));
    result.Append(String.Format(@"</div>"));
}

It’s built this was since it’s being generated for an accordion (jQuery).

So, the issue is in the foreach loop. When the code is running in the “Home” area it’s fine, but when it’s running outside of the home area, it generates odd results.

So, for example, I have a record in the database call OPS. It should create a link to OPS/OPS/INDEX (area = OPS, Controller = OPS, Action = INDEX). In the home “area”, it’s fine, but when it’s in an area, it comes out “http://localhost:17416/Home/OPS/OPS/INDEX&#8221;

Any help that can provided would be great!

Thanks in advance everyone.

  • 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-24T13:50:17+00:00Added an answer on May 24, 2026 at 1:50 pm

    use this:

    String.Format(
        "<a href='{0}'>some text you want</a>",
        Url.Action("ActionName", "ControllerName", new { area = "AreaName" })
        );
    

    instead of:

    String.Format(
        @"<a href='{0}/{1}/{2}'>{3}</a> <br />",
        sm.AreaName == null ? String.Empty : sm.AreaName,
        sm.ControllerName,
        sm.ActionName, sm.Name)
    

    for example:

    String.Format(
        "<a href='{0}'>{1}</a>",
        Url.Action(sm.ActionName, sm.ControllerName, new { area = sm.AreaName }),
        sm.Name
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
I am having the same issue as described here - http://blog.qumsieh.ca/2009/09/08/jquery-autocomplete-extraparams-and-checkboxes/ In short, when
I am having an issue with MVC-3 generating outgoing routes for me. This is
I'm having a slight issue with ActionScript 3 and I have come here to
I am having issues with javascript functionality not working in the admin area. When
Having an issue with random individuals trying to access an intranet site with a
The issue I'm having is issue with is I'm trying to get the paintComponent
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm having an issue with my regex. I want to capture <% some stuff
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. 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.