NetLearner on ASP .NET Core 3.1

By Shahed C on December 30, 2019

In This Article:

NetLearner: What is it?

NetLearner is an ASP .NET Core web app to allow any user to consolidate multiple learning resources all under one umbrella. The codebase itself is a way for new/existing .NET developers to learn ASP .NET Core, while a deployed instance of NetLearner can be used as a curated link-sharing web application.

NetLearner on GitHub: https://github.com/shahedc/NetLearnerApp

Restrictions

Registration for each web app has been disabled by default. To enable registration, please do the following:

  1. Locate scaffolded Identity pages under /Areas/Identity/Pages/Account/
  2. In Register.cshtml, update the page to include environments in addition to Development, if desired.
  3. In Register.cshtml.cs, replace [Authorize] with [AllowAnonymous] to allow access to registration

Architecture

The current version of NetLearner on Github includes a shared .NET Standard Class Library, used by multiple web app projects. The web apps include:

  • MVC: familiar to most ASP .NET developers
  • Razor Pages: relatively new in ASP .NET
  • Blazor: the latest offering from ASP .NET
NetLearner Archicture: Web App + API
NetLearner Archicture: Web App + API

Future updates will also include:

  • Web API, exposed for use by other consumers
  • JavaScript front-end web app(s)

Note that an ASP .NET Core web app can contain various combinations of all of the above. However, the purpose of the NetLearner application code is to demonstrate how to achieve similar results using all of the above. So, each of the web app projects will be developed in parallel, using a shared library.

Shared Library

The shared library is a .NET Standard 2.1 library. This version was selected because .NET Core 3.x supports .NET Standard 2.1, as seen in the official documentation.

.NET Standard: https://docs.microsoft.com/en-us/dotnet/standard/net-standard

The shared library contains the following:

  • Database Context: for use by Entity Framework Core
  • Migrations: for EF Core to manage the (SQL Server) db
  • Models: db entities, used by web apps
  • Services: service classes to handle CRUD operations

Using terms from Clean Architecture references, you may think of the DB Context and Migrations as part of the Infrastructure code, while the Models and Services are part of the Core code. For simplicity, these are all kept in a single library. In your own application, you may split them up into separate assemblies named Core and Infrastructure.

Running the Application

In order to run the web app samples, clone the following repository:

NetLearnerhttps://github.com/shahedc/NetLearnerApp

Here, you will find at least 4 projects:

  1. NetLearner.SharedLib: shared library project
  2. NetLearner.Blazor: Blazor server-side web project
  3. NetLearner.Mvc: MVC web project
  4. NetLearner.Pages: Razor Pages web project

To create a local copy of the database:

  1. Open the solution file in Visual Studio 2019
  2. In the Package Manager Console panel, change the Default Project to “NetLearner.SharedLib” to ensure that EF Core commands are run against the correct project
  3. In the Package Manager console, run the Update-Database command
  4. Verify that there are no errors upon database creation

To run the samples from Visual Studio 2019:

  1. Run each web project one after another
  2. Navigate to the links in the navigation menu, e.g. Lists and Resources
  3. Add/Edit/Delete items in any of the web apps
  4. Create one or more lists
  5. Create one more resources, assign each to a list
  6. Verify that your data changes are reflected no matter which web app you use
NetLearner MVC: Resource Lists
NetLearner MVC: Resource Lists
NetLearner MVC: Learning Resources
NetLearner MVC: Learning Resources

NetLearner Razor Pages: Resource Lists
NetLearner Razor Pages: Resource Lists
  NetLearner Razor Pages: Learning Resources
NetLearner Razor Pages: Learning Resources
   NetLearner Blazor: Resource Lists
NetLearner Blazor: Resource Lists
    NetLearner Blazor: Learning Resources
NetLearner Blazor: Learning Resources

What’s Next?

In 2020, you can expect a new A-Z weekly blog series to cover 26 different topics from January through June 2020. To get a sneak peek of what’s to come, take a peek at the 2019 A-Z series.

36 thoughts on “NetLearner on ASP .NET Core 3.1

  1. Damilola Adegunwa

    I hope to try it soon. Would the app be useful in say recreating asp.net mvc app in asp.net core?? can that be extended to do aspnet-webform to asp.net core??

    Reply
    1. Shahed C Post author

      Hi there… let me try to answer to the best of my ability.

      Q1. Would the app be useful in say recreating asp.net mvc app in asp.net core??

      A1. If you want to use this app as a template to create your own project, I would advise against it. You could use it as a reference instead. Also, refer to my recent post about how to create a web app project with a shared library, from scratch.

      https://wakeupandcode.com/asp-net-core-code-sharing-between-blazor-mvc-and-razor-pages/

      Q2. can that be extended to do aspnet-webform to asp.net core??

      A2. Web Forms are not supported on ASP .NET Core. Instead, current/former Web Forms developers are encouraged to take a look at Blazor as a possible alternative.

      Reply
  2. Pingback: Dew Drop – January 2, 2020 (#3103) | Morning Dew

  3. Pingback: Authentication & Authorization in ASP .NET Core 3.1 | Wake Up And Code!

  4. Pingback: Blazor Full-Stack Web Dev in ASP .NET Core 3.1 | Wake Up And Code!

  5. Pingback: Cookies and Consent in ASP .NET Core 3.1 | Wake Up And Code!

  6. Pingback: Deploying ASP .NET Core 3.1 to Azure App Service | Wake Up And Code!

  7. Pam Pierce

    Wish you hadn’t used ASP.NET Core 2.1 shared library, but 3.1 instead. I’ve only found one or two trainings that are honestly 3.1, the rest are basically 2.x saying they are 3.1, and most saying that there are “very few changes” between the versions. I disagree.

    And I think your title saying it is 3.1 is misleading. I was so excited until I read further down in the article to see you were using 2.1 shared library. Bummer. That isn’t helping me learn 3.1.

    Are you saying that you can’t do this in 3.1, that you HAVE to use 2.1 to make it work? Or that you haven’t taken the time to change things over to 3.1? Or that you want to use the 2.1 way of doing things and don’t believe in the 3.1 way of doing things? When you fully use 3.1 then please comment so I know to come back.

    To prevent maintenance issues, I am fully committed to writing new code in full 3.1. If anyone knows other training available that is fully 3.1, and hopefully talks about the 3.1 way of doing things and how it differs from 2.1 thinking and code, please leave a comment on what it is; I’d appreciate it. That would make a great article if anyone wants to write it here or elsewhere.

    Reply
    1. Shahed C Post author

      Hi Pam,

      The good news is that this article and blog series absolutely uses ASP .NET Core 3.1 from the beginning until the end, *including* the Shared Library.

      FYI: The Shared Library assembly targets NET Standard 2.1, which is a standard and not a runtime. This 2.1 version of .NET Standard maps to .NET Core 3.1, and as a result, ASP .NET Core 3.1.

      For more details on .NET Standard versioning, please refer to the following:

      * shared library setup: https://wakeupandcode.com/asp-net-core-code-sharing-between-blazor-mvc-and-razor-pages/

      * official docs: https://docs.microsoft.com/en-us/dotnet/standard/net-standard

      * Scott Hanselman article: https://www.hanselman.com/blog/HowToReferenceANETCoreLibraryInWinFormsOrNETStandardExplained.aspx

      In a nutshell: the sample code, its shared library and the articles are all using the latest version of everything.

      Thanks for commenting, and feel free to reach out with any follow-up questions.

      Hope this helps!
      – Shahed

      Reply
  8. Pingback: EF Core Relationships in ASP .NET Core 3.1 | Wake Up And Code!

  9. Pingback: Forms and Fields in ASP .NET Core 3.1 | Wake Up And Code!

  10. Pingback: Generic Host Builder in ASP .NET Core 3.1 | Wake Up And Code!

  11. Pingback: Handling Errors in ASP .NET Core 3.1 | Wake Up And Code!

  12. Pingback: IIS Hosting for ASP .NET Core 3.1 Web Apps | Wake Up And Code!

  13. Pingback: JavaScript, CSS, HTML & Other Static Files in ASP .NET Core 3.1 | Wake Up And Code!

  14. Pingback: Key Vault for ASP .NET Core 3.1 Web Apps | Wake Up And Code!

  15. Pingback: Logging in ASP .NET Core 3.1 | Wake Up And Code!

  16. Pingback: Middleware in ASP .NET Core 3.1 | Wake Up And Code!

  17. Pingback: .NET 5.0, VS2019 Preview and C# 9.0 for ASP .NET Core developers | Wake Up And Code!

  18. Pingback: Organizational Accounts for ASP .NET Core 3.1 | Wake Up And Code!

  19. Pingback: Production Tips for ASP .NET Core 3.1 Web Apps | Wake Up And Code!

  20. Pingback: Query Tags in EF Core for ASP .NET Core 3.1 Web Apps | Wake Up And Code!

  21. Pingback: Razor Pages in ASP .NET Core 3.1 | Wake Up And Code!

  22. Pingback: SignalR in ASP .NET Core 3.1 | Wake Up And Code!

  23. Pingback: Tag Helper Authoring in ASP .NET Core 3.1 | Wake Up And Code!

  24. Pingback: Unit Testing in ASP .NET Core 3.1 | Wake Up And Code!

  25. Pingback: Worker Service in .NET Core 3.1 | Wake Up And Code!

  26. Pingback: XML + JSON Output for Web APIs in ASP .NET Core 3.1 | Wake Up And Code!

  27. Pingback: YAML-defined CI/CD for ASP .NET Core 3.1 | Wake Up And Code!

  28. Pingback: Zero-Downtime* Web Apps for ASP .NET Core 3.1 | Wake Up And Code!

  29. Pingback: Validation in ASP .NET Core 3.1 | Wake Up And Code!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.