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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:25:28+00:00 2026-05-25T15:25:28+00:00

I have an older ASP.NET MVC application that uses classic web forms views. As

  • 0

I have an older ASP.NET MVC application that uses classic web forms views. As an experiment, we’ve started to mix in some razor views. Unfortunately, the default precedence for where to find the desired view isn’t what I want. MVC first looks in your /Views/ControllerName folder for aspx and ascx files. Then it moves to your /Views/Shared for aspx and ascx files. Then it starts over looking for .cshtml and .vbhtml files. What I want is for it not to go into the Shared folder until it’s exhausted all the possibilities in the /Views/ControllerName folder. How do I do this?

— UPDATE —

Here’s some additional information that might help explain what I’m after. By default, I get this search order:

~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml 

What I want is this:

~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

In other words, it shouldn’t search Shared before it searches the /Views/ControllerName folder completely.

  • 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-05-25T15:25:29+00:00Added an answer on May 25, 2026 at 3:25 pm

    After toying with it a bit, I was able to achieve what I wanted with a simple Fluent API. The extension methods remove the search locations I didn’t want from each of the view engines. The search locations are stored in .ViewLocationFormats and .PartialViewLocationFormats string arrays. So here’s the fluent API that removes the unwanted items from those arrays:

    public static class BuildManagerViewEngineFluentExtensions {
        public static BuildManagerViewEngine ControllerViews(this BuildManagerViewEngine engine) {
            return FilterViewLocations(engine, x => x.Contains("/Views/Shared/") == false);
        }
    
        public static BuildManagerViewEngine SharedViews(this BuildManagerViewEngine engine) {
            return FilterViewLocations(engine, x => x.Contains("/Views/Shared/") == true);
        }
    
        private static BuildManagerViewEngine FilterViewLocations(BuildManagerViewEngine engine, Func<string, bool> whereClause) {
            engine.ViewLocationFormats = engine.ViewLocationFormats.Where(whereClause).ToArray();
            engine.PartialViewLocationFormats = engine.PartialViewLocationFormats.Where(whereClause).ToArray();
            return engine;
        }
    }
    

    And then, in my global.asax, I added the following lines to protected void Application_Start()

    ViewEngines.Engines.Clear();
    ViewEngines.Engines.Add(new RazorViewEngine().ControllerViews());
    ViewEngines.Engines.Add(new WebFormViewEngine().ControllerViews());
    ViewEngines.Engines.Add(new RazorViewEngine().SharedViews());
    ViewEngines.Engines.Add(new WebFormViewEngine().SharedViews()); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application built in asp.net mvc using forms authentication. I am
I have an ASP.NET MVC application that uses jQuery 1.3.2. On several of the
We have a ASP.NET MVC 3 application that uses unobtrusive jQuery validation. The page
I currently have a ASP.Net MVC web application that needs to upload large files
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
I have an ASP.NET MVC web application that makes REST style web service calls
I have an ASP.Net MVC 3 application that uses a jQuery .ajax call to
I have an older web application that uses a MySQL Database (MYISAM). I noticed
In my ASP.NET MVC application I have a number of threads that wait for
I am developing an asp.net mvc web application that makes much use of jquery

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.