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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:05:55+00:00 2026-06-16T05:05:55+00:00

I have a partial view called _News that when called by itself works as

  • 0

I have a partial view called _News that when called by itself works as expected.

When I call it from another view using the following code:

<div>
  @html.Partial("_News");
</div>

It throws this error:

Object reference not set to an instance of an object

At this line of code in the view:

@foreach (var item in Model) {

Where the view is referencing the model. I realise this means that the view is not being passed the model from the Controller but I am perplexed as to why.

The Controller is called NewsController and is located in Controllers. The View is called _News and is located in Shared Views. The view calling the partial view is the default home/index page.

  • 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-06-16T05:05:57+00:00Added an answer on June 16, 2026 at 5:05 am

    If your partial needs to access data from the model, you need to pass the model into the Partial() method:

    @Html.Partial("_News", Model)
    

    MSDN: http://msdn.microsoft.com/en-us/library/system.web.mvc.html.partialextensions.partial%28v=vs.108%29.aspx

    EDIT:

    Per your comment below, I think you’re actually after this: http://haacked.com/archive/2009/11/17/aspnetmvc2-render-action.aspx – this lets you call a controller action and render the result into the current view.

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

Sidebar

Related Questions

I have a view that loads a partial view from a controller action using
I have the following code in a partial view: @model MyOrganization.MyApp.Models.ProductListing @using (Ajax.BeginForm(TagProduct, new
I have a partial view that I have created called noteEditor. That is rendered
I have a partial view that I want to basically take care of itself
I have a MVC3 partial view that is called with a model. @model SomeModel
I have a large Ruby on Rails form that has the following partial view
I have some code in a controller (HomeController.cs) that gets called from a $.get
I currently have a partial view that is called within my _Layout.cshtml, and is
I have Action which return partial view. This partial view is called from different
I have a partial view called Login.ascx that has my login boxes that 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.