diff --git a/README.md b/README.md index 21e465e..2ab23e2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,49 @@ SampleMvcWebApp =============== +## 🚀 .NET 6 Migration Progress + +**Current Status**: Foundation Phase Complete ✅ + +This repository is currently undergoing migration from .NET Framework 4.5.1 to .NET 6. The migration is being done incrementally to maintain stability and allow for thorough testing at each phase. + +### ✅ Completed (Phase 1 - Foundation) +- **New .NET 6 Project**: Created `SampleWebApp.Core` project with modern SDK-style format +- **Project Structure**: Established standard .NET 6 folder structure (Controllers/, Views/, Models/, wwwroot/) +- **Configuration**: Migrated from Web.config to appsettings.json with environment-specific configurations +- **Hosting Model**: Implemented minimal hosting pattern with modern ASP.NET Core middleware pipeline +- **Build Verification**: Project builds successfully and runs locally +- **Environment Support**: Development, Staging, and Production environment configurations + +### 🔄 In Progress / Next Steps +- Migrate existing controllers and views from `SampleWebApp` to `SampleWebApp.Core` +- Update Entity Framework 6 to Entity Framework Core +- Migrate dependency injection from AutoFac to built-in .NET 6 DI container +- Port GenericServices framework to work with .NET 6 +- Update authentication and authorization mechanisms +- Migrate static assets and client-side resources + +### 📁 Project Structure +``` +SampleMvcWebApp/ +├── SampleWebApp/ # Original .NET Framework 4.5.1 MVC5 application +├── SampleWebApp.Core/ # New .NET 6 Web Application (migration target) +├── DataLayer/ # Shared data layer (to be migrated to EF Core) +├── ServiceLayer/ # Shared service layer +├── BizLayer/ # Business logic layer +└── Tests/ # Test projects +``` + +### 🔗 Related Work +- **Ticket**: NET-15 - Create .NET Core 6 Web Application Project +- **Pull Request**: [#1](https://github.com/COG-GTM/SampleMvcWebApp/pull/1) + +--- + +## About the Original Application + SampleMvcWebApp is a ASP.NET MVC5 web site designed to show number of useful methods for building enterprise - grade web applications using ASP.NET MVC5 and Entity Framework 6. + grade web applications using ASP.NET MVC5 and Entity Framework 6. The code for this sample MVC web application, and the associated [GenericServices Framework](https://github.com/JonPSmith/GenericServices) are both an open source project by [Jon Smith](http://www.thereformedprogrammer.net/about-me/) diff --git a/SampleWebApp.Core/Controllers/HomeController.cs b/SampleWebApp.Core/Controllers/HomeController.cs new file mode 100644 index 0000000..85f4885 --- /dev/null +++ b/SampleWebApp.Core/Controllers/HomeController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; + +namespace SampleWebApp.Core.Controllers; + +public class HomeController : Controller +{ + public IActionResult Index() + { + return Content("SampleWebApp.Core - .NET 6 Web Application is running!"); + } + + public IActionResult Error() + { + return Content("An error occurred."); + } +} diff --git a/SampleWebApp.Core/Program.cs b/SampleWebApp.Core/Program.cs new file mode 100644 index 0000000..7531cb3 --- /dev/null +++ b/SampleWebApp.Core/Program.cs @@ -0,0 +1,22 @@ +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddControllersWithViews(); + +var app = builder.Build(); + +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); +} + +app.UseHttpsRedirection(); +app.UseStaticFiles(); +app.UseRouting(); +app.UseAuthorization(); + +app.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + +app.Run(); diff --git a/SampleWebApp.Core/Properties/launchSettings.json b/SampleWebApp.Core/Properties/launchSettings.json new file mode 100644 index 0000000..a6cf069 --- /dev/null +++ b/SampleWebApp.Core/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "profiles": { + "SampleWebApp.Core": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7001;http://localhost:5001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "SampleWebApp.Core.Staging": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7002;http://localhost:5002", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Staging" + } + }, + "SampleWebApp.Core.Production": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7003;http://localhost:5003", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Production" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/SampleWebApp.Core/SampleWebApp.Core.csproj b/SampleWebApp.Core/SampleWebApp.Core.csproj new file mode 100644 index 0000000..ae62656 --- /dev/null +++ b/SampleWebApp.Core/SampleWebApp.Core.csproj @@ -0,0 +1,15 @@ + + + + net6.0 + enable + enable + + + + + + diff --git a/SampleWebApp.Core/appsettings.Development.json b/SampleWebApp.Core/appsettings.Development.json new file mode 100644 index 0000000..b2204d4 --- /dev/null +++ b/SampleWebApp.Core/appsettings.Development.json @@ -0,0 +1,11 @@ +{ + "ApplicationSettings": { + "HostTypeString": "LocalHost" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SampleWebApp.Core/appsettings.Production.json b/SampleWebApp.Core/appsettings.Production.json new file mode 100644 index 0000000..863f656 --- /dev/null +++ b/SampleWebApp.Core/appsettings.Production.json @@ -0,0 +1,11 @@ +{ + "ApplicationSettings": { + "HostTypeString": "Production" + }, + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.AspNetCore": "Error" + } + } +} diff --git a/SampleWebApp.Core/appsettings.Staging.json b/SampleWebApp.Core/appsettings.Staging.json new file mode 100644 index 0000000..abd9f16 --- /dev/null +++ b/SampleWebApp.Core/appsettings.Staging.json @@ -0,0 +1,11 @@ +{ + "ApplicationSettings": { + "HostTypeString": "Staging" + }, + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SampleWebApp.Core/appsettings.json b/SampleWebApp.Core/appsettings.json new file mode 100644 index 0000000..c7487e5 --- /dev/null +++ b/SampleWebApp.Core/appsettings.json @@ -0,0 +1,15 @@ +{ + "ConnectionStrings": { + "SampleWebAppDb": "Data Source=(localdb)\\mssqllocaldb;Initial Catalog=SampleWebAppDb;MultipleActiveResultSets=True;Integrated Security=SSPI;Trusted_Connection=True" + }, + "ApplicationSettings": { + "HostTypeString": "LocalHost", + "DatabaseLoginPrefix": "jonsmith_" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SampleWebApp.sln b/SampleWebApp.sln index b474189..4d96402 100644 --- a/SampleWebApp.sln +++ b/SampleWebApp.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceLayer", "ServiceLaye EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{6D9E7904-B2AC-49E3-83A7-6B48876F46B9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApp.Core", "SampleWebApp.Core\SampleWebApp.Core.csproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AF8764F7-FBEE-48AD-AF62-23010DA35D70}" ProjectSection(SolutionItems) = preProject Licence.txt = Licence.txt @@ -56,6 +58,14 @@ Global {6D9E7904-B2AC-49E3-83A7-6B48876F46B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D9E7904-B2AC-49E3-83A7-6B48876F46B9}.Release|Any CPU.Build.0 = Release|Any CPU {6D9E7904-B2AC-49E3-83A7-6B48876F46B9}.WebWizRelease|Any CPU.ActiveCfg = WebWizRelease|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.AzureRelease|Any CPU.ActiveCfg = Release|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.AzureRelease|Any CPU.Build.0 = Release|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|Any CPU.Build.0 = Release|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.WebWizRelease|Any CPU.ActiveCfg = Release|Any CPU + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.WebWizRelease|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE