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 8053777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:57:29+00:00 2026-06-05T07:57:29+00:00

I have set up the Display Mode in Application Start event as DisplayModeProvider.Instance.Modes.Insert( 0,

  • 0

I have set up the Display Mode in Application Start event as

DisplayModeProvider.Instance.Modes.Insert( 0, new DefaultDisplayMode( "iPhone" ){
ContextCondition = ( context => 
    context.GetOverriddenUserAgent( ).IndexOf( 
        "iPhone", 
        StringComparison.OrdinalIgnoreCase ) >= 0 ) } );

Then in the controller I have return View where I specify the view name:

return View( “~/Views/Common/User/Login.cshtml”, viewModel );

And if I visit the page from the iPhone it will go directly to Login View

If I do not specify the view name:

return View( viewModel );

In this case from the iPhone I see the Login.iPhone.cshtml

Question: Is it possible to specify the name of the view but some how the DisplayModeProvider will select general or iPhone version of the cshtml file?

  • 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-05T07:57:30+00:00Added an answer on June 5, 2026 at 7:57 am

    I don’t normally like to resurrect old questions but as this one was never answered and this is one I had particular trouble finding an answer to myself, it may be worth having an answer for anyone else who comes across the same problem.

    You could add your additional locations to the ViewLocationFormats and PartialViewLocationFormats collections for the ViewEngines you are using. This way you could just specify the view name as tvanfosson suggests and MVC would find the file correctly, which should allow the mobile overriding to work it’s magic.

    Here is some code I use to override the PartialViewLocationFormats, you could also do the same using ViewLocationFormats. This is added in global.asax as part of application_start

                ViewEngines.Engines.Clear();
                var razorViewEngine = new RazorViewEngine
                {
                    PartialViewLocationFormats = new[]
                    {
                        "~/Views/{1}/{0}.cshtml",
                        "~/Views/Shared/{0}.cshtml",
                        "~/Views/{1}/EditorTemplates/{0}.cshtml",
                        "~/Views/{1}/DisplayTemplates/{0}.cshtml",
                        "~/Views/Shared/DisplayTemplates/{0}.cshtml"
                    }
                };
    

    Because this method involves clearing the viewengines collection, you will need to add in all locationFormats, even the standard ones, for all the view engines you are using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up the Blank Mode in Emacs to display tabs, spaces and
I have a dropdown list (FK) which I would like to set and display
In my main CSS file, I have my a:link selector set to display links
I have a huge set of data and want to display the data with
When you set an html element to have display: none , the content inside
I have a series of buttons that display filenames. If I set the Text
I have developed an AR application for iPad2 that uses an ImageMarker to display
I have an application that runs in fullscreen mode and has been working fine.
I have a table view in an iPhone xcode tab bar application that shows
I am having trouble setting up landscape mode in my application. I have a

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.