[Enhancement]: Best practice for constructor injection how-to (markdown page in repo)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- documentation
Research direction
Start with the linked DNN WebForms dependency-injection documentation, then review PRs #2774 and #4098 to understand the existing activation and pipeline behavior. The issue asks for a Markdown how-to page with a tightly scoped example; done means the page gives verified guidance on constructor injection with WebObjectActivator, notes any DNN-specific caveats, and links to the example.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of problem
Teams building a WebForms-pattern module (.ascx/code-behind) on DNN Platform 10.x, targeting .NET Framework 4.8, and want to use real constructor injection rather than a static service-locator pattern for module dependencies. Since .NET Framework 4.7.2, System.Web.HttpRuntime.WebObjectActivator allows true constructor injection into Page/UserControl/MasterPage. Before teams adopt it, they would want to check DNN's official guidance and current status directly.
- I have came across an earlier note (around #2774 / #4098 and the
DotNetNuke.ModulePipeline/ModuleControlPipelinework) that an initial attempt at usingWebObjectActivatorcaused crashes, possibly related toClientDependency. Has that been root-caused and resolved? IsWebObjectActivator-based construction considered safe for DNN module activation today? - The current DI docs cover MVC, Razor3, and SPA/Web API modules — is there an equivalent, officially recommended pattern for getting constructor injection specifically into a classic WebForms module's
UserControlcode-behind viaWebObjectActivator, or is property/setter injection still the supported approach for that module pattern? - Does
ModuleControlPipeline/IModuleControlPipelineinteract withWebObjectActivatorin a way teams should account for, or are they unrelated mechanisms that happen to both be part of the DI story? - For reference, the shape of wiring I have evaluated is the same as Microsoft's own (now-retired, reference-only)
AspNetWebFormsDependencyInjectionsample - settingHttpRuntime.WebObjectActivatorfromApplication_Startvia a smallIServiceProvideradapter over the container. Is that general
approach (regardless of container) known to be compatible with DNN's module activation, or is there a DNN-specific gotcha we should know about first? - Last reference - I co-created PicoContainer for Java before Depencency Injection was called that. Later, Unity container methods looked a lot like PicoContainer;s ones.
TL;DR: Current D.I best-practice codified in a how-to page would be fantastic :) :)
Sources
- DNN Platform Releases
- PR #2774 - Added Dependency Injection to all Module Patterns and Removed Circular Dependencies in Module
Pipeline - PR #4098 - Dependency Injection in WebForms
- DNN Docs --Dependency Injection: WebForms Modules
- Discussion #5625 - Microsoft .NET to .NET Core Upgrade Assistant
- DNN, .NET Core, and the Road Ahead - Mitchel Sellers
Description of solution
Markdown page talking about pattern and linking to tight example code (or project)
Description of alternatives considered
Briefly considered ServiceLocator and Singleton (dssign patterns) but the last 26 years of my career have been spent arguing against those!
Anything else?
No response
Do you plan to contribute code for this enhancement?
- Yes
Would you be interested in sponsoring this enhancement?
- Yes
Code of Conduct
- I agree to follow this project's Code of Conduct
- Dominant language
- C#
- Stars
- 1.1k
- Forks
- 791
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dnnsoftware/Dnn.Platform
-
Status: New
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dnnsoftware/Dnn.Platform#7543 · 1 comment ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dnnsoftware/Dnn.Platform#6681 ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dnnsoftware/Dnn.Platform#6051 · 4 comments ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 3/5 1-2 days Newbie friendliness 45/100
dnnsoftware/Dnn.Platform#7555 ·
Maintainers usually reply within 1 day
-
Status: New
Difficulty 4/5 3-5 days Newbie friendliness 22/100
dnnsoftware/Dnn.Platform#7554 · 5 comments ·
Maintainers usually reply within 1 day
All issues in dnnsoftware/Dnn.Platform
Similar issues
-
area-signalr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dotnet/aspnetcore#69842 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 2 days
-
bug needs-triage
Difficulty 2/5 Under an hour Newbie friendliness 78/100
microsoft/microsoft-ui-reactor#1373 ·
Maintainers usually reply within 1 day
-
Client customer-reported KeyVault needs-team-attention question Service Attention
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Azure/azure-sdk-for-net#63861 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
:watch: Not Triaged dotnet-csharp/svc fundamentals/subsvc
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day