Search code examples
c#asp.netrestasp.net-web-apirelease

Releasing an WebAPI


So I have finished my application, everything works and it has been tested.... but what now? I am somewhat new to C# and I have never been in a position that I am in now. I have a Windows server that is meant to constantly run this API, so how do I get this application out of VS? Normally I would just copy and .exe of the release build of my apps and run it like that, but that doesn't seem to work.

This sounds like a thing any C# dev should know but I can't find anything on the web, probably because "I am searching wrong", I would be really thankful I someone would show me where I can learn this part of development :D

EDIT: Thank you all for suggestions, I feel like I left out important information about the goals of my API. This API would run locally on my companies network, my employees have a good VPN on all of our devices and they are the only ones who would use the API anyways, so I felt like running it locally is the way to go for now.


Solution

  • You're looking for how to "Publish". This article https://www.c-sharpcorner.com/UploadFile/3d39b4/publish-and-host-Asp-Net-web-api/ will get you most of the way I'd say.

    In a (really) rough summary:

    1. Publish your code which will create the files you need a "publish" folder in the source project
    2. Set up a site in IIS on the server (I guess you might need to set up a database too)
    3. Copy the files to the server and make any changes you need to appsettings.json for things like db connection strings.