How to do it...

  1. Open up Command Prompt by running it as administrator. In Command Prompt, go to the srcAspNetCore directory of your project. Ensure that you have a folder called publish in your temp folder on the C: drive of your computer, then type in the following command, and press Enter. This will build and publish your project:
        dotnet publish --output "c:temppublish" --configuration release
Depending on what you called your ASP.NET Core application, the folder name under your src folder will be different to what mine is.
  1. After the app has been published you will see the published files along with all their dependencies in the output folder:
  1. Going back to Command Prompt, run the application by typing in dotnet AspNetCore.dll. Take note that if your ASP.NET Core application is called something else, the DLL you will run will be different from the example in the book.

You can now go to your browser and type in http://localhost:5000. This will display your ASP.NET Core application for you:

  1. You can do exactly the same on macOS by copying the published files to a folder and typing dotnet AspNetCore.dll in Terminal:

Then in Safari on your Mac, type in http://localhost:5000 and press Enter. This will load the site in Safari:

While I have just shown Safari running on macOS as an alternative, the ASP.NET Core application will run happily on Linux too.
  1. Publishing the application to IIS is also easily done. In Visual Studio, right-click on the project in the Solution Explorer and click on Publish... from the context menu:
  1. You then need to select a publish target. There are a few options available to you, but for this example, you need to select the File System option and click on OK:
  1. Back in the publish screen you can modify additional settings by clicking on Settings... next to the Target Location path. Here you need to select the publishing to be done in Release mode. Finally, click on the Publish button.
  1. When the app has been published, Visual Studio will display the results in the Output window along with the publish location you selected:
  1. In your browser, if you enter http://localhost you will see the default page for IIS. This means that IIS is set up:
  1. In Windows Explorer, browse to C:inetpubwwwroot and create a new folder called netcore. Copy the published files from your ASP.NET Core application into this new folder you created. In IIS, add a new website by right-clicking on the Sites folder and selecting Add Website. Give the site a name and select the path you copied the published files to in the Physical path setting. Lastly, change the Port to 86 as port 80 is used by the default website and click on OK:
  1. You will see your website added to the Sites folder in IIS. Under the Browse Website heading in the right-hand panel of IIS Manager, click on Browse *.86 (http):
  1. This will launch your ASP.NET Core application inside your default browser:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.163.229