diff --git a/Controllers/ApiControllerBase.cs b/Controllers/ApiControllerBase.cs new file mode 100644 index 0000000..794d6da --- /dev/null +++ b/Controllers/ApiControllerBase.cs @@ -0,0 +1,6 @@ +namespace Hua.WebTools.Controllers +{ + public class ApiControllerBase + { + } +} diff --git a/Controllers/NetWorkController.cs b/Controllers/NetWorkController.cs new file mode 100644 index 0000000..c5ba9d7 --- /dev/null +++ b/Controllers/NetWorkController.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Hua.WebTools.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class NetWorkController:ControllerBase + { + [HttpGet("[action]")] + public IActionResult GetIp() + { + return Ok(HttpContext.Connection.RemoteIpAddress.ToString()); + } + } +} diff --git a/Hua.WebTools.csproj b/Hua.WebTools.csproj new file mode 100644 index 0000000..5419ef0 --- /dev/null +++ b/Hua.WebTools.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/Hua.WebTools.sln b/Hua.WebTools.sln new file mode 100644 index 0000000..d639cad --- /dev/null +++ b/Hua.WebTools.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35521.163 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hua.WebTools", "Hua.WebTools.csproj", "{ACE90519-09D9-4D32-9531-82F04239D84A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ACE90519-09D9-4D32-9531-82F04239D84A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ACE90519-09D9-4D32-9531-82F04239D84A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ACE90519-09D9-4D32-9531-82F04239D84A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ACE90519-09D9-4D32-9531-82F04239D84A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..a9e8d7f --- /dev/null +++ b/Program.cs @@ -0,0 +1,36 @@ + +namespace Hua.WebTools +{ + public class Program + { + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + + builder.Services.AddControllers(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(); + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + + app.UseAuthorization(); + + + app.MapControllers(); + + app.Run(); + } + } +} diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..ec0da28 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:17702", + "sslPort": 44383 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5088", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7080;http://localhost:5088", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} 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": "*" +}