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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:20:22+00:00 2026-05-27T03:20:22+00:00

I am creating a breadcrumb partial view which takes in a collection of title/URL.

  • 0

I am creating a breadcrumb partial view which takes in a collection of title/URL. The collection will be generated in action methods and would have to be available on the breadcrumb partial view.

I tried couple of ways to get it done and this is one among such: http://goo.gl/rMFlp

But some how i could not get it working. All i get is an “Object reference not set to an instance of an object.” Can you guys help me out?

{Updare}
Here is the code:

I created a Model class as follows

public class ShopModel
{
    public Dictionary<string,string> Breadcrumb { get; set; }
}

Action Method

public ActionResult Index()
    {
        var breadcrumbCollection = new Dictionary<string,string>();
        breadcrumbCollection.Add("/home","Home");
        breadcrumbCollection.Add("/shop","Shop");

        var model = new ShopModel() { Breadcrumb = breadcrumbCollection};

        return View(model);
    }

Model binding the view – Index

@Model NexCart.Model.Model.Custom.ShopModel

Finally here is the code on partial view:

<div>
@{
    foreach (var item in @Model.Breadcrumb)
    {
        <a href="#">@item.Key</a>
    }
    }

  • 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-27T03:20:22+00:00Added an answer on May 27, 2026 at 3:20 am

    You haven’t shown any code, so your question is impossible to answer. This being said here’s how you could proceed. As always in an ASP.NET MVC application you start by defining a view model:

    public class Breadcrumb
    {
        public string Title { get; set; }
        public string Url { get; set; }
    }
    

    then you could write a controller action which will populate a collection of breadcrumbs and pass them to a partial view:

    public class BreadcrumbController: Controller
    {
        public ActionResult Index()
        {
            // TODO: pull the breadcrumbs from somewhere instead of hardcoding them
            var model = new[]
            {
                new Breadcrumb { Title = "Google", Url = "http://www.google.com/" },
                new Breadcrumb { Title = "Yahoo", Url = "http://www.yahoo.com/" },
                new Breadcrumb { Title = "Bing", Url = "http://www.bing.com/" },
            };
            return PartialView(model);
        }
    }
    

    then you could have a corresponding partial view which will render this model (~/Views/Breadcrumb/Index.cshtml):

    @model IEnumerable<Breadcrumb>
    <ul>
        @Html.DisplayForModel()
    </ul>
    

    and the corresponding display template (~/Views/Breadcrumb/DisplayTemplates/Breadcrumb.cshtml):

    @model Breadcrumb
    <li>
        <a href="@Model.Url">@Model.Title</a>
    </li>
    

    Now all that’s left is to include this child action somewhere using the Html.Action helper. For example you could do this in the _Layout if this breadcrumb is repeated on each page:

    @Html.Action("Index", "Breadcrumb")
    

    But obviously it could also be done in any view.

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

Sidebar

Related Questions

Creating a server-side socket will fail if I'm trying to use the same port
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
I am trying to imitate this tutorial about creating a simple Apple-themed breadcrumb found
Creating a browser based single-page browser based RIA. Would like to make use of
Creating a Blackberry app. Just a beginner, I have searched but couldn't find a
I'm essentially creating a vertical breadcrumb to create a website navigation for a mobile
I have a really hard time grasping the concept of creating a category tree.
Creating an index MySQL After I have added the FULLTEXT index, how do I
import grails.plugin.spock.* class EventControllerSpec extends ControllerSpec { def Creating a breadcrumb from an event()

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.