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..1b19413 100644 --- a/Controllers/LandingController.cs +++ b/Controllers/LandingController.cs @@ -1,16 +1,21 @@ -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() + [ApiController] + [Route("api/[controller]")] + public class LandingController : ControllerBase { - return View(); + [HttpGet] + public IActionResult Get() + { + return Ok(new { message = "ASP.NET Core 7 Web API is running", timestamp = DateTime.UtcNow }); + } + + [HttpGet("health")] + public IActionResult Health() + { + return Ok(new { status = "healthy", service = "angularjs-aspnetcore-webapi" }); + } } - } } 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..69a69ae --- /dev/null +++ b/Program.cs @@ -0,0 +1,48 @@ +using Microsoft.Extensions.FileProviders; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddControllers(); +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +builder.Services.AddCors(options => +{ + options.AddPolicy("AllowAngularJS", policy => + { + policy.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader(); + }); +}); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseCors("AllowAngularJS"); + +app.UseStaticFiles(); + +app.UseStaticFiles(new StaticFileOptions +{ + FileProvider = new PhysicalFileProvider( + Path.Combine(builder.Environment.ContentRootPath, "node_modules")), + RequestPath = "/node_modules" +}); + +app.UseRouting(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.MapFallbackToFile("index.html"); + +app.Run(); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..12f750e --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:51267", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7000;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Views/Landing/Index.cshtml b/Views/Landing/Index.cshtml deleted file mode 100644 index 92d72ed..0000000 --- a/Views/Landing/Index.cshtml +++ /dev/null @@ -1,26 +0,0 @@ - -@using System.Web.Optimization -@{ - Layout = null; -} - - - - -
- - - -