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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:18:49+00:00 2026-05-31T10:18:49+00:00

I used the following tutorial to help me build an RSS Reader in my

  • 0

I used the following tutorial to help me build an RSS Reader in my ASP.NET MVC3 Razor application:

http://weblogs.asp.net/jalpeshpvadgama/archive/2011/08/17/creating-basic-rss-reader-in-asp-net-mvc-3.aspx

However, unlike the tutorial example, I want the RSS feed to be displayed on every page, and have therefore added it to my layout file, /Views/Shared/_Layout.cshtml

I currently only have 2 views on my site, and to get the RSS Reader to work on both views I’ve got the following code in my HomeController:

    public class HomeController : Controller
    {
        //
        // GET: /Index/

        public ActionResult Index()
        {
            return View(CT.Models.RssReader.GetRssFeed());
        }

        public ActionResult About()
        {
            return View(CT.Models.RssReader.GetRssFeed());
        }

    }

From my WebForms experience, I would simply add the RSS Reader code in my master page code behind, and it would automatically work on every page.

Is there a Controller for layout pages which allows me to do the same?

How can I get this to work on every call of the layout page, without having to return anything?


EDIT: Following @Sebastian’s advice, I’ve now added this code to a Partial View, removed CT.Models.RssReader.GetRssFeed() from return View() and included this in my layout file:

 @Html.Partial("_MyPartialView")

The code in this partial view is:

<ul>
    @foreach (var item in Model)
    {
      <li>
         <a href="@item.Link" target="_blank">@item.Title</a>
      </li>
    }
</ul>

However, I’m not getting a runtime error:

Object reference not set to an instance of an object.

It’s erroring on the line @foreach (var item in Model)

  • 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-31T10:18:50+00:00Added an answer on May 31, 2026 at 10:18 am

    You have to create a partial view and add functionality there.
    Then in your layout, render this partial.

    EDIT

    Is your partial view really a partial view? The reason I said that is because you have “_” in front of the name which suggests that it might be a layout (might just be a naming convention).

    To fix object reference error, you have to add the @Model declaration on top of your partial view.

    Hope it helps.

    UPDATE
    In order to use different model in partial view, you need to explicitly declare which model you are going to use on render partialmethod.

    @{Html.RenderPartial("../YourFeed", Model.YourFeedModel);}
    

    Let me know if that resolved your issue.

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

Sidebar

Related Questions

sending mail along with embedded image using asp.net I have already used following but
Hope someone can help me. I have used the following tutorial as a guide
Hi I have used the following tutorial to send email from my application :
I used the following tutorial to create a featured content slider for my homepage
I just read the following section of the SWIG and Python tutorial: http://www.swig.org/Doc1.1/HTML/Python.html#n11 I
Hi i used the following code from this tutorial to list all of the
I am following the Ruby on Rails tutorial by Michael Hartl http://ruby.railstutorial.org/ I installed
I'm following their tutorial: http://www.stillnetstudios.com/drag-and-drop-sort-order-with-scriptaculous/ The example shown doesn't work. I've also used their
I used following code, but it displays only 2 digit of ISO country name.
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as

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.