[RESOLVED]MVC5 cannot show the .Mobile.cshtml

when I use the mobile visit my site,but MVC cannot show the mobile view.Why

firelamb

MVC cannot show the mobile view

Have you suffixed your view for mobile devices?

Can you check you are getting proper user agent?

Hi firelamb,

Thanks for your post.

I also think you can check if you are  getting proper useragent,like this:

string strUserAgent = Request.UserAgent.ToString().ToLower();
if (strUserAgent != null)
{
    if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") || 
        strUserAgent.Contains("mobile") || 
        strUserAgent.Contains("windows ce"))
{
//do something
}
}

More information:

#Mobile Device Detection and Redirection Using ASP.NET/MVC

http://www.codeguru.com/csharp/.net/net_asp/miscellaneous/article.php/c16481/Mobile-Device-Detection-and-Redirection-Using-ASPNETMVC.htm

#Creating Mobile-Optimized Views in ASP.NET MVC 4

http://msdn.microsoft.com/en-us/magazine/dn296507.aspx

Best Regards,

Eileen

Leave a Reply