{"id":19133294,"url":"https://github.com/kkgthb/web-site-dotnet-01-tiny","last_synced_at":"2025-06-24T09:38:18.333Z","repository":{"id":164101915,"uuid":"620059052","full_name":"kkgthb/web-site-dotnet-01-tiny","owner":"kkgthb","description":"Code for a teeny-tiny .NET backend/API web server (Hello World!)","archived":false,"fork":false,"pushed_at":"2023-03-28T18:02:37.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T12:12:10.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/kkgthb.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":"2023-03-28T00:23:01.000Z","updated_at":"2023-08-25T15:17:36.000Z","dependencies_parsed_at":"2024-03-22T07:01:14.777Z","dependency_job_id":null,"html_url":"https://github.com/kkgthb/web-site-dotnet-01-tiny","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkgthb%2Fweb-site-dotnet-01-tiny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkgthb%2Fweb-site-dotnet-01-tiny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkgthb%2Fweb-site-dotnet-01-tiny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkgthb%2Fweb-site-dotnet-01-tiny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kkgthb","download_url":"https://codeload.github.com/kkgthb/web-site-dotnet-01-tiny/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240214563,"owners_count":19766263,"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":[],"created_at":"2024-11-09T06:21:55.845Z","updated_at":"2025-02-22T17:40:15.783Z","avatar_url":"https://github.com/kkgthb.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The smallest ASP.NET backend-API website you can easily run on your local computer\r\n\r\n---\r\n\r\n## Prerequisites\r\n\r\n1. You must install the .NET runtime _(preferably version 7, as that's what I coded this using)_ onto your local machine in a way that lets you run commands beginning with \"`dotnet`\" from your computer's command prompt _(the \"dotnet\" executable must be in your \"PATH.\")_.\r\n    * Don't have Windows admin rights?  Check out David Kou's [Install the .NET runtime onto Windows without admin rights](https://dev.to/davidkou/install-anything-without-admin-rights-4p0j#install-dotnet-sdk-or-runtime-without-admin).\r\n2. You must download a copy of this codebase onto your local computer.\r\n\r\n---\r\n\r\n## Building source code into a runtime\r\n\r\nOpen up a command line interface.\r\n\r\nEnsure that its prompt indicates that your commands will be running within the context of the folder into which you downloaded a copy of this codebase.\r\n\r\nRun the following command:\r\n\r\n```sh\r\n(cd ./src/web \u0026\u0026 dotnet publish --configuration Release --output ../../my_output \u0026\u0026 cd ../..)\r\n```\r\n\r\nThe above command should execute within a second or two.\r\n\r\n* It will add a new subfolder called `/bin/` as well as one called `/obj/` into `/src/web/` within the folder on your computer containing a copy of this codebase, but you can ignore those.\r\n* More importantly, it will add a new subfolder called `/my_output/` into the top level of the folder on your computer containing a copy of this codebase.\r\n\r\nCongratulations -- you have now built an executable \"runtime\" for ASP.NET that, when executed, will behave as a web server.\r\n\r\nThe entirety of your \"runtime\" that you just built lives in the `/my_output/` folder.  It should contain about 6 files, including one called `Handwritten.exe`.\r\n\r\n---\r\n\r\n## Running your web server\r\n\r\nOpen up a command line interface.\r\n\r\nEnsure that its prompt indicates that your commands will be running within the context of the folder into which you downloaded a copy of this codebase.\r\n\r\nRun the following command:\r\n\r\n```sh\r\n./my_output/Handwritten.exe\r\n```\r\n\r\n* **WARNING**:  Do _not_ close the command line just yet or it will be difficult to stop your web server later in this exercise.\r\n\r\nThe output you will see will say something like:\r\n\r\n```\r\ninfo: Microsoft.Hosting.Lifetime[14]\r\n      Now listening on: http://localhost:5000\r\ninfo: Microsoft.Hosting.Lifetime[0]\r\n      Application started. Press Ctrl+C to shut down.\r\ninfo: Microsoft.Hosting.Lifetime[0]\r\n      Hosting environment: Production\r\ninfo: Microsoft.Hosting.Lifetime[0]\r\n      Content root path: C:\\example\r\n```\r\n\r\n---\r\n\r\n## Visiting your website\r\n\r\nOpen a web browser and navigate to [http://localhost:5000/api/sayhello](http://localhost:5000/api/sayhello) _(being sure to use an alternative port number to `5000` if indicated \"`now listening on`\" message you saw when you executed your runtime)_.\r\n\r\nTake a look in the upper-left corner of the webpage you just visited:  it should say \"**Hello World**\".\r\n\r\n---\r\n\r\n## Stopping your web server\r\n\r\nGo back to the command line interface from which you ran `./my_output/Handwritten.exe`.\r\n\r\nHold \u003ckbd\u003eCtrl\u003c/kbd\u003e and hit \u003ckbd\u003ec\u003c/kbd\u003e, then release them both.\r\n\r\n---\r\n\r\n## A build CI/CD pipeline for Azure DevOps Pipelines\r\n\r\nI'm not sure I'll get around to making cloud instructions for this codebase any time soon, so if you'd like to guess your way through adapting lessons from [az-as-wa-001-node-express-tiny](https://github.com/kkgthb/az-as-wa-001-node-express-tiny) to apply to this codebase instead, here's the \"build pipeline\" YAML I used in Azure DevOps Pipelines:\r\n\r\n```yaml\r\ntrigger:\r\n- main\r\n\r\npool:\r\n  vmImage: \"windows-latest\"\r\n\r\nsteps:\r\n\r\n- task: UseDotNet@2\r\n  displayName: \"Install .NET Core SDK\"\r\n  inputs:\r\n    version: 7.x\r\n    performMultiLevelLookup: true\r\n    includePreviewVersions: true\r\n\r\n- task: DotNetCoreCLI@2\r\n  displayName: \"DotNet Publish\"\r\n  inputs:\r\n    command: publish\r\n    workingDirectory: \"src/web\"\r\n    arguments: \"--configuration Release --output $(Build.ArtifactStagingDirectory)\"\r\n    zipAfterPublish: True\r\n\r\n- task: PublishBuildArtifacts@1\r\n  displayName: \"Publish build-artifact from staging directory to named artifact\"\r\n  inputs:\r\n    PathToPublish: \"$(Build.ArtifactStagingDirectory)\"\r\n    ArtifactName: \"MyBuiltDotNetWebsite\"\r\n```\r\n\r\nThe \"published artifact\" output of running such a pipeline against this repository should be a folder called `MyBuiltDotNetWebsite` with one `.zip`-typed file in it.  If you were to download the `.zip` file to your computer _(click its name in the published artifact file-tree browser)_ and open it, its contents would look like those of the `/my_output/` folder you saw on your desktop computer earlier _(approximately 6 files, including one called `Handwritten.exe`)_.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkgthb%2Fweb-site-dotnet-01-tiny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkkgthb%2Fweb-site-dotnet-01-tiny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkgthb%2Fweb-site-dotnet-01-tiny/lists"}