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

  • Home
  • SEARCH
  • 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 6472997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:24:46+00:00 2026-05-25T06:24:46+00:00

I have one (razor) page that contain 5 different partial views. Each partial view

  • 0

I have one (razor) page that contain 5 different partial views. Each partial view is responsible for some data from database. In that master page I use one model object but for partial views I use different model objects. The problem is that when I set model object in partial view my application breaks with following error:
The model item passed into the dictionary is of type 'MyProject.WebUI.Models.BigPageViewModel', but this dictionary requires a model item of type 'MyProject.WebUI.Models.StatisticsViewModel'.

Here is the code:
This is the big page that contains partial views:

@model MyProject.WebUI.Models.BigPageViewModel
@{
    Layout = "../Shared/_BigPage.cshtml";
}
...
@{Html.RenderPartial("../Data/StatisticsFeed");}
...

This is controller code. For this method I created partial view that should be rendered in big page.

public ActionResult StatisticsFeed()
        {
            StatisticsViewModel cs = new StatisticsViewModel();
            cs.TotalData = (new StatisticsRepository()).GetStatisticCompleteData(1);
            return View(cs);
        }

And this is the code in partial view:

@model MyProject.WebUI.Models.StatisticsViewModel
...

enter image description here

I used ‘RenderAction’ method instead of ‘RenderPartial’ and it return value but returns me two results one with data and one without, this must be some stupid mistake…

public ActionResult StatisticsFeed()
        {
          StatisticsViewModel cs = new StatisticsViewModel();
                cs.TotalData = (new StatisticsRepository()).GetStatisticCompleteData(1);

            cs.TotalCitizns = 569;
            return View(cs);
        }
  • 1 1 Answer
  • 1 View
  • 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-25T06:24:47+00:00Added an answer on May 25, 2026 at 6:24 am

    You need to specify explicitly the model being passed to the partial using the second argument of the RenderPartial method. If you don’t specify it the parent model is passed and so the exception you get:

    @{Html.RenderPartial("../Data/StatisticsFeed", Model.SomePropertyOfTypeStatisticsViewModel);}
    

    Another possibility is to use RenderAction:

    @{Html.RenderAction("StatisticsFeed", "ControllerName");}
    

    This will invoke the StatisticsFeed controller action which itself will fetch the model from the database and render the results.

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

Sidebar

Related Questions

I have one page that will contain a lot data. Outline of the page
I have a section of Razor code in one of my views that isn't
Using MVC3 Razor, I have a partial view with some text, two text boxes
I have one aspx page with some controls. Also i have one DIV which
This one is strange...I have the following markup for a view using Razor view
I am trying out the MVC3 Razor view engine, and one the features that
I have an ASP.NET MVC 3 page ( Razor ) that consists of a
I have a razor cshtml view that uses jquery. I get following error during
I have one field that I need to sum lets say named items However
I have one thread that writes results into a Queue. In another thread (GUI),

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.