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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:05:55+00:00 2026-05-27T17:05:55+00:00

I have a custom View Engine that derives from WebFormViewEngine. There’s a lot of

  • 0

I have a custom View Engine that derives from WebFormViewEngine. There’s a lot of stuff going on in here, mostly caching. I want to be able to use WebFormViewEngine AND RazorViewEngine at the same time, is this possible? Ideally I’d like to do;

ViewEngines.Add(new MyViewEngine<WebFormsViewEngine>());
ViewEngines.Add(new MyViewEngine<RazorViewEngine>());

if a .ascx/.aspx/.master file exists then use WebForms, otherwise use Razor is a .cshtml file exists.

EDIT: I should of worded my question better. As my custom view engine derives from WebFormViewEngine it obviously uses WebForms, I can’t derive from two classes. I can derive from RazorViewEngine but then I’ll loose WebForms. I can duplicate my code entirely, derive from RazorViewEngine and edit the views file extensions, etc. but as I said I’ve got a lot of custom code in my view engine and would be duplicating hundreds of lines.

WebFormViewEngine and RazorViewEngine derive from BuildManagerViewEngine which in turn implements IViewEngine. The problem with that is I have to implement methods CreatePartialView() and CreateView() but how would I know what to return (WebForms/Razor?) using generics?

  • 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-27T17:05:56+00:00Added an answer on May 27, 2026 at 5:05 pm

    In the end I ended up with creating an abstract class: public abstract class MyViewEngine : BuildManagerViewEngine, IViewEngine { } and then implement/override the FindView and FindPartialView methods (which had my caching code in). I had an abstract method public abstract void SetSearchPaths(); that was called in my ctor.

    I then created another class that derived from MyViewEngine for WebForms specifically:

    public class MyViewEngineWebForms : MyViewEngine
    {
        public override void SetSearchPaths()
        {
            base.MasterLocationFormats = new string[] { "~/Skins/{2}/Views/{1}/{0}.master", "~/Skins/{2}/Views/Shared/{0}.master" };
            base.ViewLocationFormats = new string[] { "~/Skins/{2}/Views/{1}/{0}.aspx", "~/Skins/{2}/Views/Shared/{0}.aspx", "~/Skins/Shared/Views/{0}.aspx" };
            base.PartialViewLocationFormats = new string[] { "~/Skins/{2}/Views/{1}/{0}.ascx", "~/Skins/{2}/Views/Shared/{0}.ascx", "~/Skins/Shared/PartialViews/{0}.ascx" };
            base.FileExtensions = new string[] { "aspx", "ascx", "master" };
        }
    
        protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath)
        {
            return new WebFormView(controllerContext, partialPath, null, base.ViewPageActivator);
        }
    
        protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
        {
            return new WebFormView(controllerContext, viewPath, masterPath, base.ViewPageActivator);
        }
    }
    

    and did exactly the same for Razor but change the file extensions to .cshtml/.vbhtml and change WebFormView to RazorView. Add them to the ViewEngine collection:

    ViewEngines.Engines.Clear();
    ViewEngines.Engines.Add(new SeeTicketsWebFormsViewEngine());
    ViewEngines.Engines.Add(new SeeTicketsRazorViewEngine());
    

    and now they work perfectly again, side by side with all of my custom caching logic.

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

Sidebar

Related Questions

I have my custom view extended from View . There are 3 view constructors:
I have a custom view subclassed from GridView that I use in order to
I have a custom view engine in ASP.NET MVC and since upgrading to RC1
I have a custom control/view that observes the direction of a gesture within its
I have a custom-made view that extends the View class. I would like 2
I have a simple custom view that is connected via outlet to a NIB.
I have the following situation: There is one custom view inside of the first
I have a view that I want to add some custom drawing to. I
HI have a custom view class that is loaded and placed within my main
I have a custom view controller that I push onto my navigation stack as

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.