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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:14:14+00:00 2026-05-30T23:14:14+00:00

I am creating advanced site that is based in 99% on one view. I

  • 0

I am creating advanced site that is based in 99% on one view. I have created the following code which is responsible to point all controllers actions which dont have corresponding view to universal view: ~/Views/Shared/UniversalView.cshtml.

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    foreach (IViewEngine engine in ViewEngines.Engines)
    {
        if (engine is RazorViewEngine)
        {
            RazorViewEngine razorEngine = (RazorViewEngine)engine;
            var locationFormats = razorEngine.ViewLocationFormats;
            List<string> l = new List<string>(locationFormats);
            l.Add("~/Views/Shared/UniversalView.cshtml");
            razorEngine.ViewLocationFormats = l.ToArray();
        }
    }
}

I am preety sure that there will be much better method to achive that effect. Any ideas?

  • 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-30T23:14:15+00:00Added an answer on May 30, 2026 at 11:14 pm

    You can declare a BaseController and all your controller must inherit from it.

    Then just add a method in BaseController like

        public ViewResult UniversalView(string viewName="UniversalView")
        {
            return View(viewName);
        }
    

    From other controllers you can call this method instead of traditional View().
    If you will specify the view name it will take that view else default is Universal view.

        public ActionResult About()
        {
            return UniversalView();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a site that requires a very small postcode checker. I have
Hello all I am creating a horizontal menu for a site that needs to
I'm writing a site in ASP.NET MVC that will have user accounts. As the
This site is built using CakePHP 1.2* I have an element that needs to
I am creating a site on which content will be stored for several different
I am tasked with creating an uploader for a site that can handle very
Using DTS I'm dynamically creating an access database. After the file is created (which
I have to build a site that receives some custom report from my users
I'm creating a webapp where upon connecting to my server, you will have one
I am creating a site with Codeigniter. I have to show the customers profile

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.