When you want any application available publicly, you need to host it on the server and before hosting, it requires certain processes in terms of making an Application code suitable to the host. Thus, in this article, we will learn how to publish ASP.NET Web API Applications, using File system method. Therefore, let's start step by step, so beginners can also understand.
Publishing is the process to make an Application code suitable to host on the Server by merging multiple class codes into DLLs and by keeping only the required UI code.
The Web Application goes through the steps, mentioned below before hosting to the Server.
Develop an Application -- Publish an Application - Host an Application on IIS.
Now, just demonstrate the preceding concept step by step; i.e, how to publish ASP.NET Web API Applications practically.
Step 1 : Create ASP.NET Web API application
If you want to publish any Application, first we need to create the Application. If you don't know how to create ASP.NET Web API Application, please refer to my previous article, mentioned below.
Step 2: Publish an Application
Step 3: Select Publish TargetNow, select the option, where you want to save the published file. There are lots of options given by Visual Studio to save the published files, as shown below.
- Microsoft Azure App Service
This is one of the services provided by Microsoft Azure to publish the different types of the Application such as Web, mobile, REST and other into Azure (Cloud). You need a Microsoft Azure subscription to use this option.
This option is used to publish the Application, which is based on the predefined configuration files given by your hosting provider , which will directly publish the files in your hosting provider environment.
This option is used to publish the Application into your own machine location or FTP Server, as per your most convenient way.
- Microsoft Azure API apps This option is used to publish REST API's Services in Cloud.
- Microsoft Azure virtual machineThis option is used to publish the Application in Microsoft Azure virtual machine (Cloud), which requires an Azure subscription .
Step 4: Create Custom profileNow, in this article, we are going to publish an Application in our local machine file system, so we need to choose custom target option. First, we need to create the profile to publish the Application, so it can be a consistent setting to publish the same Application in the future. Choose custom option from preceding explained target option, as shown below.
Step 5: Choose Publish MethodNow, configure the created profile, which decides where and how to publish the files. Select the Publish method from the number of methods, which are shown below.
Step 6: Choose File System locationNow, choose the target location of your local system in which you want to store the published files, as shown below.
Step 7: Choose Publish code typeNow, choose what type of code you want in production environment by choosing release or debug option, as shown below.
- DebugChoose this option when you want to debug your Application after the hosting.
- ReleaseChoose this option when you do not want to debug the Application after hosting and make the Application faster .
Step 8: Preview the configurationAfter the configuration, publish configuration tool will look like, as shown below.
Now, click Publish option and watch the output Window, as shown below.
Now, as shown in the preceding screenshot's highlighted section, our Application code is published in our specified file system location. Now, navigate to the target folder and see the published files, as shown below.
- Choose the publish target location, as per your system.
- Select proper publish method, as per your requirement.
I hope, this article is useful for all the readers. If you have any suggestions, please contact me.