Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net MVC4 Wrong Views Displayed (.mobile issues)

Recently I added a mobile version of the site using MVC4 .mobile views. I structured the site in a very similar way to the desktop version by starting from _Layout.mobile.cshtml which pointed to the correct scripts and css designed specifically for the mobile site.

After publishing the site I checked that everything worked correctly which it did just as how it was designed. But shortly I was told that the site was broken. When checking the mobile site I noticed that the _Layout.mobile.cshtml was loaded but instead of the Index.mobile.cshtml which is sent from the Home controller, what was returned instead was the standard Index.cshtml designed for desktop. The desktop Index file was also rendered using the mobile css which caused the whole mobile site to look very messed up. On a side note, no changes occurred to the desktop version of the site.

Republishing fixed the issue, but I also noticed that sometimes it reverts back to displaying the correct views without republishing even after it broke.

I began to research the issue and what I stumbled across discussions about Display Modes not working such as this: ASP.NET MVC 4 Mobile Display Modes Stop Working

With a NuGet solution that read as deprecated: http://www.nuget.org/packages/Microsoft.AspNet.Mvc.FixedDisplayModes

I assumed that since this discussion was from a year ago talking about early releases it should be fixed by more recent MVC4 updates. My current version was 4.0.20710.0 so I updated to 4.0.30506 using NuGet before doing anything else.

This did not solve the issue but not only that, upon inspecting I noticed the reference System.Web.MVC was still pointing towards the 4.0.20710.0 version dll file.

I am worried about adding an unnecessary fix that is labeled deprecated and was hoping that the MVC update would resolve this issue. Any suggestions?

like image 882
Roman Khrystynych Avatar asked Aug 29 '13 21:08

Roman Khrystynych


1 Answers

the package in your link is the package for the pre-release Asp.Net MVC 5. Indeed, they did solve the issue you are having in the Asp.Net MVC 5 package, but it is still pre-release with Visual Studio 2013. In the additional links on the page, there is a link for the non-beta, non-RC release that still applies to Asp.Net MVC 4 (FixedDisplayModes)

like image 61
Claies Avatar answered Jan 04 '23 07:01

Claies