Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make one ASP.NET MVC site "derive" from another

My question is similar to "ASP.NET 2 projects to share same files", but with an ASP.NET MVC slant.

Basically, we have two sites, one being based mostly on the other (roughly 90% views, controllers, images, in the second are identical to the first). However, in some cases, the views may be different, or a controller in the second site may be different to the first.

Are there any simple ways of achieving this in ASP.NET MVC?

So far, we've looked at using linked files to have two totally seperate projects where the second project shares the files it needs from the first.

One problem with this approach is that most pages in the second project don't literally exist in the virtual directory, it makes debugging a pain - you have to publish in order to generate the files so you can debug.

Does anyone have any better approaches, or ways this approach can be simplified?

like image 227
Rob Levine Avatar asked May 19 '10 16:05

Rob Levine


People also ask

Can we plug an ASP NET MVC into an existing ASP NET application?

Luckily, the answer is yes. Combining ASP.NET Webforms and ASP.NET MVC in one application is possible—in fact, it is quite easy. The reason for this is that the ASP.NET MVC framework has been built on top of ASP.NET.

Does ASP support inheritance?

TPH is the only inheritance pattern that the Entity Framework Core supports. What you'll do is create a Person class, change the Instructor and Student classes to derive from Person , add the new class to the DbContext , and create a migration.

What is default URL in MVC?

As you can see in the above figure, the route is configured using the MapRoute() extension method of RouteCollection , where name is "Default", url pattern is "{controller}/{action}/{id}" and defaults parameter for controller, action method and id parameter.


1 Answers

This article might help: http://dotnetslackers.com/articles/aspnet/storing-asp-net-mvc-controllers-views-in-separate-assemblies.aspx

Essentially, it involves creating your own WebFormViewEngine which tells MVC where to look for the Views.

like image 129
Daniel Dyson Avatar answered Oct 03 '22 22:10

Daniel Dyson