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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:45:26+00:00 2026-05-13T06:45:26+00:00

I have an MVC masterpage set up which loads a dynamic menu using AJAX

  • 0

I have an MVC masterpage set up which loads a dynamic menu using AJAX Templates and JSON – the JSON is returned with the following call:

var tabList = []; //this holds the json data on the callback

var getTabs = function () {
    $.getJSON('Home/TabList', null, function (json) {
        Sys.Observer.clear(tabList); 
        Sys.Observer.addRange(tabList, json); 
    });
}

if (tabList == '') { getTabs(); }

So this calls a function on my HomeController to return JSON:

   public JsonResult  TabList()
    {
            //get tabs
            ... //call code to get tabs - removed for ease of reading this question
            JsonResult jsonTabs = Json(tabItems);

            jsonTabs.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            return jsonTabs;
        }
        catch (Exception ex)
        { throw ex; }

    }

This is used in the following template:
binding:

id=”tabTemplate” sys:attach=”dataview” class=”sys-template grid_16 topnav” dataview:data=”{{ tabList }}”

creating the menu items using an anchor tag:

sys:href=”{{‘/’ + Controller + ‘/’ + Action + ‘/’}}” target=”_top”

Populating the menu text using a property from the JSON object:

{{Text}}

I then attached this master page to 2 different MVC pages (“Index” and “About”, and global.asax takes me to “Index”)

So, this works great the first time I go in to the page, and the menu is drawn correctly, but when I click the About menu item which has been generated in the above template with the link “Home/About” then it stops working. What happens is that the javascript is called correctly (i.e. it calls the “getTabs” function and passes through the getJSON call) BUT it doesn’t actually hit my controller to get the JSON (I put a brekpoint on the controller action and it is not hit in this case).

I am totally at a loss and have been trying to solve this for days. Any help would be greatly 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-13T06:45:27+00:00Added an answer on May 13, 2026 at 6:45 am

    I think it may be because your .getJSON request is calling the relative path Home/TabList.

    When you are on the home page, e.g. http://localhost/, the .getJSON request will call http://localhost/Home/TabList which, as you say, works.

    BUT then when you are on a subsequent page, e.g. http://localhost/Home/About the .getJSON request will call http://localhost/Home/About/Home/TabList which, as you say, won’t work 🙂

    Anyway, try calling the absolute path /Home/TabList

    E.g.

    $.getJSON('/Home/TabList', null, function (json) {
    

    NOTE: The extra forward slash at the beginning.

    HTHs,
    Charles

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC-based site, which is using a Repository/Service pattern for data access.
I have the whole MVC-Model set up and use HTML views as templates. But
I have an MVC view with a form built with the Ajax.BeginForm() helper method,
I have an MVC application that among other things contains a small Silverlight menu
I have an .Net MVC application which runs fine if I use the build
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I'm using a masterpage in my ASP.NET MVC project. This masterpage expects some ViewData
Does ASP.NET MVC have anything like the RESTful out-of-the-box features like Ruby on Rails
ASP.NET MVC routes have names when mapped: routes.MapRoute( Debug, // Route name -- how
I am playing around with MVC and have started setting up an existing site

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.