Hi @Aparesh Dev
I just wanted to automate the hosting process of my site. so can you please suggest if there are any set of command, by using this we can do the same.
Whether your site is an Asp.net core Application or not? If it is an Asp.net core application, you can use the following method:
You can use the System.Diagnostics.Process class in C#, you can use this class to start the command-line process and runs the dotnet run
command in the specified working directory (your Asp.net Core project root path), then it will host your site.
Refer to the following sample: In the TestIdentity solution, there have a WebApplication3 project, I will use the following C# code (in a console project) to host the WebApplication3 project.
using System.Diagnostics;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C dotnet run";
startInfo.WorkingDirectory = @"C:\Users\Administrator\source\repos\TestIdentity\WebApplication3";
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
After that the result as below:
You can replace dotnet run
with any other command that you want to run.
Besides, if you want to deploy the application on the hosting server, see Host and deploy ASP.NET Core.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion