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 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
  • 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-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 view page, of which the content ain't always the same, ie:
I have one array that contains some settings that looks like basically like this:
Have one. Fla (Flash) file that uses ActionScript 1.0. Need to have it in
In MVC3 Razor, how do you create a page with multiple forms, so that
I have a SELECT element on one of my jQuery Mobile pages that has
I have the following markup as a part of a Razor view: <table> <caption>Presidents</caption>
I have one domain on godaddy (www.mydomain.com). I have placed my cakephp application on
i have one trouble, me need make scrollview with content of pdf(pages), this content
i have one file. it contains fields like this i/p files : a.txt 9842,5003,a,a,100
I have one big php application running on php 4 but I want to

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.