diff --git a/App_Start/BundleConfig.cs b/App_Start/BundleConfig.cs deleted file mode 100644 index 13718c4..0000000 --- a/App_Start/BundleConfig.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Optimization; - -public class BundleConfig -{ - public static void RegisterBundles(BundleCollection bundles) - { - // Bundle JavaScript files. - bundles.Add(new ScriptBundle("~/bundles/scripts") - .Include("~/node_modules/jquery/dist/jquery.min.js") - .Include("~/node_modules/angular/angular.min.js") - .IncludeDirectory("~/WebApp", "*.js", false) - .IncludeDirectory("~/WebApp/Components", "*.js", true) - .IncludeDirectory("~/WebApp/Directives", "*.js", true)); - - // Bundles CSS files - bundles.Add(new StyleBundle("~/bundles/styles") - .IncludeDirectory("~/Content", "*.css", true) - .IncludeDirectory("~/WebApp", "*.css", true)); - } -} diff --git a/App_Start/RouteConfig.cs b/App_Start/RouteConfig.cs deleted file mode 100644 index 336e299..0000000 --- a/App_Start/RouteConfig.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; - -namespace asp_net_angularjs -{ - public class RouteConfig - { - public static void RegisterRoutes(RouteCollection routes) - { - routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); - - routes.MapRoute( - name: "Landing", - url: "", - defaults: new { controller = "Landing", action = "Index", id = UrlParameter.Optional } - ); - } - } -} diff --git a/Controllers/LandingController.cs b/Controllers/LandingController.cs index 2888a1c..11aba09 100644 --- a/Controllers/LandingController.cs +++ b/Controllers/LandingController.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; +using Microsoft.AspNetCore.Mvc; namespace asp_net_angularjs.Controllers { public class LandingController : Controller { - public ActionResult Index() + public IActionResult Index() { return View(); } diff --git a/Global.asax b/Global.asax deleted file mode 100644 index 5a72af9..0000000 --- a/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="asp_net_angularjs.MvcApplication" Language="C#" %> diff --git a/Global.asax.cs b/Global.asax.cs deleted file mode 100644 index 4d07a6e..0000000 --- a/Global.asax.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Web.Mvc; -using System.Web.Routing; -using System.Web.Optimization; - -namespace asp_net_angularjs -{ - public class MvcApplication : System.Web.HttpApplication - { - protected void Application_Start() - { - AreaRegistration.RegisterAllAreas(); - RouteConfig.RegisterRoutes(RouteTable.Routes); - BundleConfig.RegisterBundles(BundleTable.Bundles); - } - } -} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..94f3001 --- /dev/null +++ b/Program.cs @@ -0,0 +1,47 @@ +using Microsoft.Extensions.FileProviders; + +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.UseStaticFiles(new StaticFileOptions +{ + FileProvider = new PhysicalFileProvider( + Path.Combine(builder.Environment.ContentRootPath, "node_modules")), + RequestPath = "/node_modules" +}); + +app.UseStaticFiles(new StaticFileOptions +{ + FileProvider = new PhysicalFileProvider( + Path.Combine(builder.Environment.ContentRootPath, "Content")), + RequestPath = "/Content" +}); + +app.UseStaticFiles(new StaticFileOptions +{ + FileProvider = new PhysicalFileProvider( + Path.Combine(builder.Environment.ContentRootPath, "WebApp")), + RequestPath = "/WebApp" +}); + +app.UseRouting(); + +app.MapControllerRoute( + name: "Landing", + pattern: "", + defaults: new { controller = "Landing", action = "Index" }); + +app.Run(); diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs deleted file mode 100644 index bf6d758..0000000 --- a/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("asp_net_angularjs")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("asp_net_angularjs")] -[assembly: AssemblyCopyright("Copyright © 2022")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("43046e18-f0d2-4443-98d5-4650bdcb3a8b")] - -// Version information for an assembly consists of the following four values: -// Major Version -// Minor Version -// Build Number -// Revision - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..82f4174 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:51267", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/README.md b/README.md index aec5e26..9a2ec19 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# AngularJS with .NET Framework -A demo project using AngularJS, .NET Framework 4.8, and ASP.NET MVC 5. +# AngularJS with .NET 7 + +A demo project using AngularJS with .NET 7 and ASP.NET Core MVC. ## Features - XLTS for AngularJS - installed using npm - jQuery 3.6.3 - installed using npm -- .NET Framework 4.8 -- ASP.NET MVC 5 -- Bundling using [Microsoft.AspNet.Web.Optimization](https://docs.microsoft.com/en-us/aspnet/mvc/overview/performance/bundling-and-minification) +- .NET 7 +- ASP.NET Core MVC +- Cross-platform (runs on Windows, macOS, and Linux) ## Prerequisites -- Windows 10/11 - Older versions of Windows may work but have not been tested. -- [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) - The free *Community Edition* is sufficient. -Older versions of Visual Studio may work but have not been tested. -- [.Net Framework 4.8](https://dotnet.microsoft.com/en-us/download/dotnet-framework) - This can optionally be installed -as part of the Visual Studio 2022 installation as well. +- [.NET 7 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) +- Node.js >= 18 +- npm >= 9 ## Getting Started + - Make sure you have configured your authentication with the XLTS.dev registry by supplying your token in the `.npmrc` file in your user home directory. > **Note** @@ -26,9 +26,16 @@ as part of the Visual Studio 2022 installation as well. - Clone repository: `git clone https://github.com/xlts-dev/angularjs-asp-net48-mvc5.git`. - Switch to the project's directory: `cd angularjs-asp-net48-mvc5`. - Install npm packages: `npm install`. -- Open the project in Visual Studio. -- Run the project by pressing the `F5` key or using the green start button in the toolbar. This will launch your web - browser and display the web application. +- Run the project: `dotnet run`. +- Open your browser and navigate to `http://localhost:51267`. ## AngularJS LTS packages + If you want to use the LTS packages, you have to run `npm run switch-to-lts-packages` script instead of `npm install`. + +## Running Tests + +Run the Playwright end-to-end tests: +```bash +npm run e2e +``` diff --git a/Views/Landing/Index.cshtml b/Views/Landing/Index.cshtml index 92d72ed..b96c5dd 100644 --- a/Views/Landing/Index.cshtml +++ b/Views/Landing/Index.cshtml @@ -1,5 +1,4 @@ -@using System.Web.Optimization @{ Layout = null; } @@ -11,15 +10,23 @@ - XLTS for AngularJS with .NET Framework + XLTS for AngularJS with .NET 7 - @Styles.Render("~/bundles/styles") - @Scripts.Render("~/bundles/scripts") + + + + + + + + + + -

XLTS for AngularJS with .NET Framework

+

XLTS for AngularJS with .NET 7

diff --git a/Views/_ViewImports.cshtml b/Views/_ViewImports.cshtml new file mode 100644 index 0000000..deeece2 --- /dev/null +++ b/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using asp_net_angularjs +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Views/web.config b/Views/web.config deleted file mode 100644 index 4502e7d..0000000 --- a/Views/web.config +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Web.Debug.config b/Web.Debug.config deleted file mode 100644 index 26ad76e..0000000 --- a/Web.Debug.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/Web.Release.config b/Web.Release.config deleted file mode 100644 index ea1b727..0000000 --- a/Web.Release.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Web.config b/Web.config deleted file mode 100644 index cf8e2f3..0000000 --- a/Web.config +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/angularjs-asp-net48-mvc5.csproj b/angularjs-asp-net48-mvc5.csproj index 2d3d3e0..ddb9106 100644 --- a/angularjs-asp-net48-mvc5.csproj +++ b/angularjs-asp-net48-mvc5.csproj @@ -1,177 +1,9 @@ - - + - Debug - AnyCPU - - - 2.0 - {43046E18-F0D2-4443-98D5-4650BDCB3A8B} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties + net7.0 + enable + enable asp_net_angularjs asp-net-angularjs - v4.8 - true - - - - - - - - - packages\WebGrease.1.5.2\lib - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - true - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll - - - packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll - - - - packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - packages\Newtonsoft.Json.5.0.4\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll - - - packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll - - - packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll - - - packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll - - - packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll - - - packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll - - - packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll - - - - - - - - - - packages\WebGrease.1.5.2\lib\WebGrease.dll - - - - - - - - - - - - - - - - - - - - - - Global.asax - - - - - - - - - Web.config - - - Web.config - - - - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 0 - / - http://localhost:51267/ - False - False - - - False - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/e2e/tests/app.e2e.js b/e2e/tests/app.e2e.js index 9b64f44..f7f5789 100644 --- a/e2e/tests/app.e2e.js +++ b/e2e/tests/app.e2e.js @@ -12,18 +12,18 @@ test.describe('angularjs-asp-net48-mvc5 app', () => { test('Index', async ({ page }) => { const indexPage = new IndexPage(page); - await expect(indexPage.title).toHaveText('XLTS for AngularJS with .NET Framework'); + await expect(indexPage.title).toHaveText('XLTS for AngularJS with .NET 7'); }); test('TestComponent', async ({ page }) => { const testComponentPage = new TestComponentPage(page); - await expect(testComponentPage.angularjsVersion).toHaveText('AngularJS Version: 1.8.2'); + await expect(testComponentPage.angularjsVersion).toHaveText('AngularJS Version: 1.8.3'); }); test('TestDirective', async ({ page }) => { const testDirective = new TestDirectivePage(page); - await expect(testDirective.jqueryVersion).toHaveText('jQuery Version: 3.6.0'); + await expect(testDirective.jqueryVersion).toHaveText('jQuery Version: 3.7.0'); }); }); diff --git a/packages.config b/packages.config deleted file mode 100644 index a35fc87..0000000 --- a/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - -