Search code examples
asp.net-corerazordeploymentrazor-pages

Deploying dot net core 2 Razor pages website to shared hosting


I created a website using Razor pages (asp .net core 2.0), nothing fancy, no database, pretty much kind of static website. Reason I used .cshtml is mostly so I can have template / _Layout, etc.

I created it using VS 2017.

Now I need to deploy it. I'm using just a standard shared host, but not sure how to do it.

I tried to copy the folders under wwwroot: css/images/js/lib through ftp

But wasn't sure were to put the Pages folder?

Also, is it need to be build and compile?

When I run it locally the VS 2017 builds and serve it.

How do I deploy to shared host?

When I click build - publish in the menu, it created a folder under: bin\Release\netcoreapp2.0\publish\

but it has many files inside - many dll's , etc. Do I just copy this folder to the server?

Where should I copy all the files from publish in the serve? Inside wwwroot? in the parent folder of wwwroot?

Thanks.


Solution

  • Your ASP.NET Core Razor Pages application need to be compiled for deployment to a hosting system for execution. And those files with a .dll extension in output folder are the project's code in Intermediate Language (IL) files and other libraries that project depends on.

    For the wwwroot that you mentioned:

    In ASP.NET Core Razor Pages projet, we normally store and serve public, static resource files under wwwroot folder. For more information about serving static files in ASP.NET Core, please check following doc(s):

    On IIS server, typically, the default Web site root is configured at c:\inetpub\wwwroot. You can create another new website and specify physical path to other location that you expect.

    Besides, to host an ASP.NET Core app on an IIS server, you can check the following tutorial to setup required hosting environment.

    https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio