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 .
What is Publishing ?
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.
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.
I hope, you have created ASP.NET Application by reading the preceding article .
Publish an ApplicationRight click on the created ASP.NET Web API project solution, as shown below.
Now, click the previously shown Publish option. It will open the Windows, mentioned below.
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 .
There are many other options to publish the Application, using which we can publish .NET Application.
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.
Now, give the profile name as per your requirement and click OK. It will create the custom profile, as per your given name.
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.
Now, choose the file system method from preceding methods and click Next button.
Choose File System locationNow, choose the target location of your local system in which you want to store the published files, as shown below.
In the preceding screenshot, we have selected the target location E drive to store the published files. It may be different in your case, as per you machine and click Next button .
Choose Publish code typeNow, choose what type of code you want in production environment by choosing release or debug option, as shown below.
Now, let's learn in brief about debug and release option.
- 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 .
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.
We have seen our published code, which is used to host in IIS. I hope from all the preceding examples, we learned how to publish ASP.NET Web API Service in File system .Note
- 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.