Successful Deployment WebRole - Mobile Views DO NOT Work
-
Montag, 23. Juli 2012 14:52
I finally was able to get a MVC4 web role app deployed... granted it was just the startup app.... had to fix connection string and mark referenced assemblies to Copy Local = True... but then it deployed successfully... YAY!!!
But now... I'm just making a simple Mobile layout... adding _Layout.Mobile.cshtml... and changing some text to show that it's a mobile view for testing purposes.... IT DOES NOT WORK....
When viewing on Desktop... desktop view shows correctly as usual... but when viewing on mobile device... Android and iPad were used... it display Desktop version still and NOT mobile view...??
Website is http://sky-test.cloudapp.net
Copyright at bottom of screen should say "My Mobile MVC Application", not "My ASP.NET MVC Application" on mobile devices...?
Alle Antworten
-
Dienstag, 24. Juli 2012 03:40Moderator
Hi,
I suggest you download samples with MVC mobile application with Nuget:
http://nuget.org/packages/MobileViewEngines.Razor.Sample
Or you can got more info from this blog:
http://blog.kurtschindler.net/post/exploring-aspnet-mvc-4-mobile-features
Hope this helps.
Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
-
Dienstag, 24. Juli 2012 12:53
That's a great suggestion and I'll go ahead and look at those links...
however...
We moved a "working" MVC4 implementation with Mobile Views from GoDaddy Cloud VM's to Azure VM's and it stopped working once on the Azure VM's.... thus we obviously thought the problem was with Auzre VM's fyi.....
-
Dienstag, 24. Juli 2012 13:12Nope... looked at blog and as i thought... it's pretty hard to screw up Mobile views... says right on the blog it should work right out of the box.... created a _Layout.Mobile.cshtml file (right alongside the _Layout.cshtml file).... works in debug and on development... but doesn't work once deployed to cloud web role... In development I'm changing user agent of browser to see Mobile views render as expected... Why wouldn't this be working on the Cloud Web Role?
-
Montag, 30. Juli 2012 13:27
Turns out for every mobile device OTHER than iPhone, you must explicitly add it to navigate to the mobile view in the global.asax on Windows Azure web roles and vm's.... see code snippet below:
using System.Web.WebPages;
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
{
ContextCondition = (ctx => ctx.Request.UserAgent != null
&& (ctx.Request.UserAgent.IndexOf("Android", StringComparison.OrdinalIgnoreCase) >= 0
|| ctx.Request.UserAgent.IndexOf("Mobile", StringComparison.OrdinalIgnoreCase) >= 0
|| ctx.Request.UserAgent.IndexOf("Opera Mobi", StringComparison.OrdinalIgnoreCase) >= 0
|| ctx.Request.UserAgent.IndexOf("Opera Mini", StringComparison.OrdinalIgnoreCase) >= 0))
});- Als Antwort markiert zenopm Montag, 30. Juli 2012 13:27

