Deploying a website
Deploying your website is the process of compiling (building) your code and hosting the DLL file on a web server.
This section builds on the previous step in the Getting Started tutorial and shows you how to deploy your application.
Prerequisites
A best practice is to run your website locally before you deploy it to another environment. To run your project locally, you need to install the .NET SDK on your computer.
Running your website locally
- Prepare the website. You can follow the Getting Started steps to create your own website or download the Blazor Server Online Shop project from Github.
- Open a cmd in the root folder of the project and use the
run
command, it will build and run the project. Note that you need to open the cmd in the root project not the root solution.
dotnet run
- If you run successfully, you will see the following messages coming from the cmd.
The website runs on ports 5000 and 5001 by default for Kestrel. To view the website, navigate to the http://localhost:5000 or https://localhost:5001.
Publishing and hosting your website
- To publish your website for production, use the
publish
command.
dotnet publish -c Release -o "YourFolder"
By default, publish
command uses the debug build configuration. For production ready, you need to specify the -c Release
to specify build by release configuration. The -o "YourFolder"
part is to specify the output folder, if you don't specify the output folder, you can see the published files at [project_folder]/bin/[configuration]/[framework]/publish/ folder by default.
- Copy the content of the published folder to your web server. Since these files are executable, hosting on each website is significantly different. You can host your website in IIS, NGINX, Apache, Kubernetes, Azure, AWS, Google Cloud We will have a deeper look at each popular web server later on.
What's next
In this tutorial, you have learned the foundation to explore the Blazor Server world in areas such as UX/UI development, mobile development, and server-side rendering, web assembly interacting, javascript interacting. You can go deeper by studying more of Blazor Server's features, engaging with the vibrant community, and exploring the robust ecosystem.
Learning more Blazor Server
To explore Blazor Server's foundational concepts, see the guides in the Understanding Blazor Server section.