Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:39:00+00:00 2026-06-07T04:39:00+00:00

I noticed in MVC4, there is a built in method called Request.Browser.IsMobileDevice. How do

  • 0

I noticed in MVC4, there is a built in method called Request.Browser.IsMobileDevice. How do I use this to check if the request is a mobile then redirect to the controller and action of /mobile/index? I want to carry over any query strings and the location hash that was in the URL. Is there a built in way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:39:02+00:00Added an answer on June 7, 2026 at 4:39 am

    Generally you wouldn’t want to redirect to a different controller and action for a mobile device since a mobile device should just require a different representation of the same model (you wouldn’t want to duplicate your controller logic). If you create a view with the .Mobile.cshtml extension (for C# Razor views), MVC4 will, by convention, use this view for mobile devices.

    E.g. if you have this view in your Home folder

    Index.cshtml
    

    by adding this view to your Home folder

    Index.Mobile.cshtml
    

    MVC4 will render Index.Mobile.cshtml on mobile devices and Index.cshtml on non mobile devices.

    That said, there may be times when it is necessary to do something specific for mobile devices. E.g. if you wanted a different _Layout.cshtml for mobile devices, you could place the following in your _ViewStart.cshtml file

    @{
        if(Request.Browser.IsMobileDevice)
        {
            Layout = "~/Views/Shared/_Layout.Mobile.cshtml";
        }
        else
        {
            Layout = "~/Views/Shared/_Layout.cshtml";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed a method called Post in Android's Button class. I was wondering what
I noticed django use this to process the string, but can I get a
Noticed this today when a patch was submitted with the following line: lblCompletionTime.Text =
I noticed that there are two sets of Hadoop configuration parameters: one with mapred.*
I noticed that IE 9 does not support application cache. How can I use
I noticed something when I was attempting to use remoteField ajax tag in grails.
Noticed a strange thing today. I have some code like this in a project
I noticed when the MVC4 beta was announced, it includes a new Web-API .
Noticed this urls.py definition in an open source django app. r'^(?P<username>(?!signout|signup|signin)[\.\w]+)/$ How do I
I noticed that when I do something like this (with jQuery, but I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.