user3734945
user3734945

Reputation: 1

Can a new MVC page inherit functionality from an existing Web Form page?

I currently am working on a website that has been established using the webforms model. However there is one page in particular that would be easier to develop using the MVC model. I know it is possible to mix the two types through some configuration. My question is: is it possible to create this page using the MVC model but have it inherit from a Webform?

For example, if I were to create this page in the normal webforms page I would simply set:

    public partial class NewPage : HomeBasePage

Since the HomeBasePage (webform) is used by every other page in the site I am concerned if this will be a problem making this new page in MVC and still being consistent in the inheritance.

Upvotes: 0

Views: 196

Answers (1)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93494

No.

MVC and WebForms are two entirely different models and do not work in the same way. WebForms uses a "page based" system, while MVC uses a "Controller based" system. This means that MVC doesn't have pages. It has actions.

This is a fundamental distinction, and is why WebForms have code behinds, and MVC separates actions from their views.

More fundamentally, WebPages inherit from the Page class. MVC actions inherit from Controller. They are entirely different, and no way you can mix them. In addition, MVC and WebForms follow very different page lifecycles, and have very different execution pipelines.

However,

You do not provide enough information about what it is that HomeBasePage actually does. Perhaps there is some way to reuse some of that functionality in a different way, but without knowing what that is... we can't tell you anything.

Upvotes: 1

Related Questions