-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Is Modular Web Application in vNext Possible? #4572
Comments
In RC2, MVC added a concept called ApplicationParts to help address some of these scenarios. Also with the .NET CLI things will always be on disk so "produce outputs on build" will go away as a concept.
Can you be more specific?
The layout is simplified in RC2 as well, it'll be a flat list of assemblies like it was before. However, it's still your job to copy the right things into the right places. If you don't reference a project the tool chain has no idea that it should be copied side by side. Specifically:
If there's no dependency between
Don't know what this means. |
Thank you for the answer @davidfowl.
Sorry, I was referring to the cons of using a framework.
As of now (RC1), locating a documentation on how to do that is difficult.
Thanks, this is a great news. Eagerly waiting for the RC2 release. |
@javiercn @sebastienros do you guys have any additional thoughts on this? |
Exactly what @davidfowl is saying. Orchard detects these dependencies at runtime then registers them using |
Is there a documentation on |
Here is how we add the assemblies for the modules we have discovered in the case of Orchard:
|
Yes, ApplicationParts are designed for this scenario. You can access the application part manager on IMvcBuilder. Here are a couple of examples on how to add and remove assemblies to the list of application parts public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
var builder = services
.AddMvc()
.AddApplicationPart(typeof(TimeScheduleController).GetTypeInfo().Assembly)
}
... Remove an assembly from the list of application parts: public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
var builder = services
.AddMvc()
.ConfigureApplicationPartManager(manager => {
var assembly = typeof(TypeInAssembly).GetTypeInfo().Assembly;
var part = manager.ApplicationParts.OfType<AssemblyPart>().First(p => p.Assembly == assembly);
manager.ApplicationParts.Remove(assembly);
});
}
... |
@davidfowl With |
I'm dreamming for this. |
I have made a sample app, using ApplicationParts to add assemblies, wrote ModuleViewLocationExpander to help looking up the right folder for views, and serve static content for each modules. https://github.com/thiennn/trymodular. Comments are welcomed |
How would you go about prefixing routes? For example module A and module B have controllers called home. How do you specify module route prefixes in the application parts so you get the following routes? Localhost/b/home By adding the application part both controllers would route to Localhost/home unless each and every controller had an attribute route applied? |
@edwardwilson you can create a default route for each module like here: https://github.com/OrchardCMS/Orchard2/blob/master/src/Orchard.Hosting.Web/Routing/OrchardRouterMiddleware.cs#L107 A custom router implementation can do that. |
We are closing this issue because no further action is planned for this issue. If you still have any issues or questions, please log a new issue with any additional details that you have. |
Adding this to the Startup.cs in .Net Core 1.1 actually works:
|
@ADefWebserver What is the content of Some Controllers and AspNet Assembles dependence? |
@alexsandro-xpt - |
Not bad @ADefWebserver !! Thank you! |
Scenario
MainWebApplication
andModuleA
.ModuleA
calledDefaultController
with an actionfoo
which returns string "bar".When you add a reference of
ModuleA
onMainWebApplication
and compile, you can see that the actionfoo
works fine.What's wrong with this?
ModuleA
should depend onMainWebApplication
because it is an extension of theMainWebApplication
. If you add a reference ofMainWebApplication
onModuleA
, the controller action is not found by ASP.NET Core.Why should you address this issue?
In my humble opinion, we have always needed to add a lot of plumbing code to achieve modular functionality in classic ASP.net. In ASP.net Core, it's more cryptic now. For example, please have a look on the
ExtCore
repository which tries to solve this problem.https://github.com/ExtCore/ExtCore
This is a bad approach because
Finally, I apologize if I missed something. Please do provide an official solution because it would ease the life of a lot of web app developers.
The text was updated successfully, but these errors were encountered: