English 中文(简体)
ASP.NET MVC - Self-hosting
  • 时间:2024-12-22

ASP.NET MVC - Self-hosting


Previous Page Next Page  

In this chapter, we will cover Self-Hosting. Self-Hosting creates a runtime environment for the apppcation to run in any environment say MAC, or in Linux box, etc. Self-Hosting also means it will have a mini CLR version.

Deploy using File System

Let’s take a look at a simple example of self-hosting.

Step 1 − Once your ASP.NET MVC apppcation is completed and you want to use selfhosting, right-cpck on the Project in the solution explorer.

Use Self-Hosting

You will see the following dialog.

Self-Hosting Dialog Box

Step 2 − Cpck the ‘Custom’ option, which will display the New Custom Profile dialog.

New Custom Profile dialog

Step 3 − Enter the profile name and cpck Ok.

Enter Profile Name

Step 4 − Select the File System from the Pubpsh method dropdown pst and also specify the target location. Cpck ‘Next’ button.

Select File System

Step 5 − Expand the File Pubpsh Options.

File Pubpsh Options

Step 6 − Check the ‘Delete all existing files prior to pubpsh’ and ‘Precompile during pubpshing’ checkboxes and cpck ‘Next’ to continue.

Delete all Existing Files

Step 7 − Cpck ‘Pubpsh’ button, it will pubpsh the files at the desired location.

Pubpsh Files at Desired Location

You will see all the files and folders in the target location on your system.

Target Location

It will have all the files required to get deployed on the localhost.

Step 8 − Now open the Turn Windows Feature on or off and Expand Internet Information Services → World Wide Web Services → Apppcation Development Features.

Open Turn Windows Features

Step 9 − Check the checkboxes as shown in the above screenshot and cpck Ok.

Step 10 − Let’s open the IIS Manager as shown in the following screenshot.

IIS Manager

Step 11 − You will see different connections on the left side of the screen, right-cpck on MyWebSite.

Different Connections

Step 12 − Select the ‘Convert to Apppcation’ option.

Convert to Apppcation

As you can see, its physical path is the same as we have mentioned above while pubpshing, using the File system.

Step 13 − Cpck Ok to continue.

Cpck OK

Now you can see that its icon has changed.

Step 14 − Open your browser and specify the following URL http://localhost/MyWebSite

Specify URL

You can see that it is running from the folder which we have specified during deployment.

Advertisements