Dmitry Sikorsky

Your First Modular ASP.NET Core Web Application Using the ExtCore Framework

We are going to create extremely simple modular ASP.NET Core web application using the ExtCore framework. It will do nothing except calling the methods (and displaying the returned values) of the objects, that are automatically instantiated by ExtCore using the types, defined inside an external module. That module might be included as an explicit dependency or as a DLL file.

Web Application Project

Let’s start by creating an empty ASP.NET Core web application project in Visual Studio 2015:

An empty web application project is created.

Open project.json file and add dependency on ExtCore.WebApplication version 1.1.0. After that dependencies section of your project.json file should look like this:

Now open Startup.cs file and inherit your Startup class from ExtCore.WebApplication.Startup. After that add constructor with IServiceProvider parameter and pass that parameter to the constructor of the parent class. Optionally you may want to add a console logger to be able to see what is going on with your web application:

Extension Project

It’s time to create the extension project:

Open project.json file and add dependency on ExtCore.Infrastructure version 1.1.0. After that dependencies section of your project.json file should look like this:

Normally extensions do something useful, but our one will only define a name. Create the Extension class and inherit it from ExtCore.Infrastructure.ExtensionBase. After that override the Name property. Your class should look like this:

Put it Together

We have two options to make our extension available in main web application:

No matter which option you choose, the result will be the same. Finally, let’s “use” our extension in the web application. Modify your Configure method of the Startup class as follows:

If we run our web application, we will have the following result:

That’s all for now. You can download this sample and try it out.

January 10, 2017 by Dmitry Sikorsky