2

I'm calling a RenderPartial from a primary view where 'user' exists:

@{Html.RenderPartial("DisplayTemplates/uInfo", user);}

Works on my dev machine but the production server is tossing that runtime error:

The partial view 'DisplayTemplates/uInfo' was not found or no view engine supports the searched locations. The following locations were searched: ...

The following locations were searched:

~/Views/Account/DisplayTemplates/uInfo.aspx
~/Views/Account/DisplayTemplates/uInfo.ascx
~/Views/Shared/DisplayTemplates/uInfo.aspx
~/Views/Shared/DisplayTemplates/uInfo.ascx
~/Views/Account/DisplayTemplates/uInfo.cshtml
~/Views/Account/DisplayTemplates/uInfo.vbhtml
~/Views/Shared/DisplayTemplates/uInfo.cshtml
~/Views/Shared/DisplayTemplates/uInfo.vbhtml

My file _is listed - Shared/DisplayTemplates/uInfo.cshtml and works locally.

In case it's relevent - i'm taking the liberties of freely switching back and forth between Razor and legacy .aspx views. Initially was concerned about possible complications of intermingling the two but up to this point everything i've tried has worked.

thx

justSteve
  • 5,444
  • 19
  • 72
  • 137

1 Answers1

0

Shouldn't it be:

@Html.DisplayFor(model => model.User)

And if the type of model.User is uInfo, MVC will by default look in the DisplayTemplates folder and find uInfo.cshtml. That is the MVC convention at work.

You shouldn't render display templates with RenderPartial.

If you want a partial view, do this:

@Html.Partial("SomePartial", user)

Still, i agree the behaviour your seeing is weird and this doensn't really answer your question - but try and adhere to MVC conventions first and foremost.

RPM1984
  • 72,246
  • 58
  • 225
  • 350
  • I've inherited the code and can't track the though-processes (or skill levels) of the dev that developed this. The call has worked (revolved and rendered) at other places in the app. I've hacked around it for the time being - would like to revisit this when i have time. thx! – justSteve Apr 13 '11 at 01:12