I am using new MVC4 mobile functionality where if you add .Mobile to a view name it renders out the mobile one if it's being viewed on a mobile device. So _Home.cshtml
becomes _Home.Mobile.cshtml
. This is working when I manually call a view: @Html.Partial("_HeaderNavigation",Model)
it loads the mobile version if appropriate.
However when I use renderBody()
it loads _Home.cshtml
instead of _Home.Mobile.cshtml
. I am using Areas, so home.cshtml
is in an area.
EDIT
Looking into it further, is it because _Home.Mobile.cshtml
is in an area called Home? Does this then not know to get the .mobile version?
I think this might be related to this well know open issue of MVC 4 mobile behind-the scenes-caching - you might try applying this patch: FixedDisplayModes
I found out that the issue was that in the controller for the home Area I was returning the full path e.g.
return PartialView(MVC.Home.Home.Views._Home, this.Page);
instead ofreturn PartialView("_Home", this.Page);
, asDove
told me to do in another question I asked.If Home is a view then it would be quite strange to have an underscore under it. The underscore is historically used for items that will not be displayed by themselves and thus not wanted to be discovered.
Can you test your set with a view called Index say under your area Home and see if that works.