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

  • Home
  • SEARCH
  • 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 8649257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:30:59+00:00 2026-06-12T13:30:59+00:00

I created a custom Razor View engine Right now when I do: public class

  • 0

I created a custom Razor View engine

Right now when I do:

public class ConfigViewEngine : RazorViewEngine
{
    public ConfigViewEngine()
    {
        var existingViewLocationFormats = new List<string>();
        var partialViewLocationFormats = new List<string>();

        //Folder Structure: Views\Desktop\Home and Views\Mobile\Home
        existingViewLocationFormats.Insert(0,
                                         "~/Views/" + ConfigurationManager.AppSettings["configName"] +
                                         "/Shared/{0}.cshtml");
        partialViewLocationFormats.Insert(0,
                                        "~/Views/" + ConfigurationManager.AppSettings["configName"] +
                                        "/Shared/{0}.cshtml");
        existingViewLocationFormats.Insert(0,
                                         "~/Views/" + ConfigurationManager.AppSettings["configName"] +
                                         "/{1}/{0}.cshtml");
        partialViewLocationFormats.Insert(0,
                                        "~/Views/" + ConfigurationManager.AppSettings["configName"] +
                                        "/{1}/{0}.cshtml");

        ViewLocationFormats = existingViewLocationFormats.ToArray();
        PartialViewLocationFormats = partialViewLocationFormats.ToArray();
    }
}

My _ViewStart.cshtml looks like

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new ConfigViewEngine());
Layout = "~/Views/" + ConfigurationManager.AppSettings["configName"] + "/Shared/_Layout.cshtml";

I get the following error when I go to /Home/Dashboard

The view 'Dashboard' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Dashboard.aspx
~/Views/Home/Dashboard.ascx
~/Views/Shared/Dashboard.aspx
~/Views/Shared/Dashboard.ascx
~/Views/Home/Dashboard.cshtml
~/Views/Home/Dashboard.vbhtml
~/Views/Shared/Dashboard.cshtml
~/Views/Shared/Dashboard.vbhtml

If I place an empty Dashboard.cshtml file in /Views/Home/, it will use that file and then when I refresh, it will serve the correct file from /Views/configName/Home/Dashboard

Anybody know why it’s not initializing correctly?

  • 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-12T13:31:00+00:00Added an answer on June 12, 2026 at 1:31 pm

    Figured it out. I wasn’t supposed to put that code in _ViewStart.cshtml, I was supposed to put it in Global.asax.cs

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

Sidebar

Related Questions

VS2010 Ultimate, ASP.NET MVC 3 w/Razor. I've created a custom view engine in my
I've created custom list: public class BList : IEnumerable<Position> { private List<Position> positions =
I have created custom exception class public class Web2PDFException : Exception { public Web2PDFException(string
We have created custom listview by using the Base adapter. List view contains Text
Using the following: MVC 3 VB.NET RAZOR VIEW engine Html Helper Class In my
I created a Custom Tab Navigator and now I need to know how can
I have created Custom Annotation with following: -(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { MKPinAnnotationView *view =
I have a telerik mvc grid in a Razor view. I am using custom
I have created a new Custom Control inheriting from Bar control of DevComponents.DotNetBar controls.
I have created a custom razor helper in my MVC4 Web application that I

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.