{"id":21823470,"url":"https://github.com/f2calv/webappdi","last_synced_at":"2025-10-26T17:17:23.415Z","repository":{"id":98598444,"uuid":"185305064","full_name":"f2calv/WebAppDI","owner":"f2calv","description":"Classic ASP.NET Web Application (.NET Framework 4.7.2) with Dependency Injection \u0026 ILogger","archived":false,"fork":false,"pushed_at":"2022-09-03T04:20:20.000Z","size":582,"stargazers_count":0,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-27T17:38:00.391Z","etag":null,"topics":["dependency-injection","devops-pipeline","netframework","webapi","webapp","yaml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/f2calv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-07T02:22:46.000Z","updated_at":"2022-09-03T04:19:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"591281ef-2f3d-49e2-b0e3-465fe0897fb2","html_url":"https://github.com/f2calv/WebAppDI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2calv%2FWebAppDI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2calv%2FWebAppDI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2calv%2FWebAppDI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2calv%2FWebAppDI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f2calv","download_url":"https://codeload.github.com/f2calv/WebAppDI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235678935,"owners_count":19028302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","devops-pipeline","netframework","webapi","webapp","yaml"],"created_at":"2024-11-27T17:32:17.281Z","updated_at":"2025-10-08T04:30:36.897Z","avatar_url":"https://github.com/f2calv.png","language":"JavaScript","readme":"# Classic ASP.NET Web Application (.NET Framework) with Dependency Injection\n\nThis repository was born out of a need for web/application developers to migrate their somewhat out-dated ASP.NET MVC web application using the .NET Framework to the newest ASP.NET MVC Core release.\n\n.NET Core as a fundamental rule uses dependency injection throughout, and ASP.NET Core is no exception to this rule, and yet a large number of traditional ASP.NET web applications do not use DI.\n\nGiven that developers and development teams are not usually given a lot of time to break apart an existing application just because they want to run on the latest all-singing and all-dancing framework, this repository serves as a simple example of how you can add DI to an existing 4.7.2 application.\n\nOnce you have added DI to your existing web application running under .NET Framework then a future migration to the .NET Core framework is much easier!\n\nSo this repository is a simple working example of how-to to get dependency injection and logging working in an older .NET Framework project using the [Microsoft.Extensions.DependencyInjection](https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/) and [Microsoft.Extensions.Logging](https://www.nuget.org/packages/Microsoft.Extensions.Logging/) packages.\n\nNote: Both of these Extenions nuget packages are multi-targeted and so will work seamlessly when you finally get around upgrade to .NET Core.\n\nThis solution was built using Visual Studio and consists of;\n- WebAppDI - ASP.NET Web Application (.NET Framework) utilising both MVC \u0026 Web API controllers\n- WebAppDILib - .NET Framework class library.\n- WebAppDI.Tests - .NET Framework class library for example unit tests.\n- AzurePipelines - example [Azure Pipelines YAML build/test](https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops\u0026tabs=schema) pipeline.\n\nBefore implementing the dependency injection, I performed some maintenance on the default project templates created by Visual Studio;\n- I created a backup of all packages.config \u0026 web.config.\n- Uninstalled all nuget packages from the Web Application project and manually deleted all binding redirects in the web.config file.\n- Change Visual Studio to use nuget package reference ([see here](https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference))\n- Re-installed the nuget packages 1-by-1 into the Web Application until the project compiled (note client libraries like jquery \u0026 bootstrap should be re-installed using [libman](https://github.com/aspnet/LibraryManager/wiki/Using-LibMan-in-Visual-Studio) however I skipped that step for the example)\n- Re-added some binding redirects into web.config which were explicitly required using values from the backup web.config taken in the first step!\n\nThe general steps I took to get DI working are as follows;\n- Added nuget packages Microsoft.Owin \u0026 Microsoft.Owin.Host.SystemWeb\n- Added a Startup.cs which contains the dependency resolvers for both MVC \u0026 Web API.\n- Added example MVC and Web API Controllers to both the main Web Application and the class library.\n- Created a test \"service\" to inject into both the Web API \u0026 MVC controllers called DITestService along with interface IDITestService.\n\nThe crucial code is in Startup.cs and in the Controller constructors which is where the dependency injection magic happens\n\nI hope this repository helps you on your journey to upgrade to ASP.NET Core...\n\nHope this helps...\n\n[![Build Status](https://dev.azure.com/f2calv/github/_apis/build/status/f2calv.WebAppDI?branchName=master)](https://dev.azure.com/f2calv/github/_build/latest?definitionId=1\u0026branchName=master)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff2calv%2Fwebappdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff2calv%2Fwebappdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff2calv%2Fwebappdi/lists"}