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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:26:18+00:00 2026-06-18T02:26:18+00:00

I have two asp.net MVC 3 web projects that uses the same views, and

  • 0

I have two asp.net MVC 3 web projects that uses the same views, and i would like to put those views in a web project that contains common items like controllers, actionfilters, Extension methods, etc… (the project folder just above those two projects).

I created this custom view engine modifying the views and partial view, locations.

public class GenericViewEngine : RazorViewEngine
    {
        public GenericViewEngine(): this(null)
        { }
        public GenericViewEngine(IViewPageActivator viewPageActivator)
        {
            base.ViewLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/../Framework.Web/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml", "~/../Framework.Web/Views/Shared/{0}.cshtml"  };
            base.MasterLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/../Framework.Web/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml", "~/../Framework.Web/Views/Shared/{0}.cshtml"  };
            base.PartialViewLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/../Framework.Web/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml", "~/../Framework.Web/Views/Shared/{0}.cshtml" };
            base.FileExtensions = new string[] { "cshtml" };
        }
        protected override IView CreatePartialView (ControllerContext controllerContext, string partialPath)
        {
            return base.CreatePartialView(controllerContext, partialPath);
        }
        protected override IView CreateView (ControllerContext controllerContext, string viewPath, string masterPath)
        {
            return base.CreateView(controllerContext, viewPath, masterPath);

        }
    }

Im getting an exception that says: Cannot use a leading .. to exit above the top directory.

How i can put the common views of these two projects out of each web projects? Is there any solution for avoid compile the views into the main common web project?

Thanks in advance.

Jose.

  • 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-18T02:26:19+00:00Added an answer on June 18, 2026 at 2:26 am

    Is there any solution for avoid compile the views into the main common web project?

    Yes, you could embed them as resources into some plugin assembly and reuse them in multiple projects. For this you will have to write a custom VirtualPathProvider that is able to load views from non-standard locations outside of your current application. You could also take a look at the RazorGenerator project. Here’s an accompanying blog post explaining some of the required steps. Basically you need to install the Razor Generator Extension which will precompile your Razor views as part of a class library that you could reference in your MVC application.

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

Sidebar

Related Questions

In the asp.net mvc 3 application I have two views which have the same
I have two projects in the same solution. One is an ASP.NET MVC 2
I have two ASP.NET MVC web applications. One of them logs unhandled exceptions to
I have two .ascx files in the same folder in an ASP.NET MVC project.
I have a Solution with several projects in it, including two asp.net mvc projects
I have two projects.One project is build in MVC asp.net and the other project
I have an older asp.net mvc solution (s#arp framework) whith two projects one for
I have a .NET solution containing two projects: An ASP.NET MVC project, 'Website' A
i have two projects Evolet.Domain and Evolet.Web in my solution where Evolet.Web is asp.net
I have two instances of an Address.ascx control in an ASP.NET MVC page. <h1>Shipping

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.