View Full Version : [CLOSED] Problem rendering partial view

Apr 26, 2012, 7:41 PM

I have the code below to render a ext partial view in my MVC3 application using Razor view engine


But I got an exception saying "Object reference not set to an instance of an object." and here is the line where the exception occurs in PartialViewRender.cs:

string path = ((WebFormView)view).ViewPath;

looks like the viewengine was casted to WebFormView even if I am using Razor. Could someone please look into this? Thanks.

Apr 26, 2012, 8:06 PM
Yes, at this moment it is not updated yet
I suggest to use panel or container and load into it

.ContentFromPage(this, "PartialRazorView.cshtml")

May 07, 2012, 2:00 AM
Is there any update on when this might be fixed?

I have a scenario where I have a page with several partial views each of which needs it's own model to render and I can't see a way that I can pass the relevant model into each partial without the RenderExtPartial method working?

May 07, 2012, 11:39 AM
It's under processing.

For now we can suggest to pass a required data via the third parameter.

.ContentFromPage(this, "~/Views/Razor/SubPage.cshtml", param1, param2)

You can access this data within a partial view using the PageData property.

Jul 03, 2012, 9:22 PM

Under Razor engine please use standard 'Html.RenderPartial'