[RESOLVED]MVC5 cannot show the .Mobile.cshtml

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


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


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


Best Regards,


Leave a Reply