![ASP.NET MVC Tutorial](/asp.net_mvc/images/asp-net-mvc-mini-logo.jpg)
- ASP.NET MVC Tutorial
- ASP.NET MVC - Home
- ASP.NET MVC - Overview
- ASP.NET MVC - Pattern
- ASP.NET MVC - Environment Setup
- ASP.NET MVC - Getting Started
- ASP.NET MVC - Life Cycle
- ASP.NET MVC - Routing
- ASP.NET MVC - Controllers
- ASP.NET MVC - Actions
- ASP.NET MVC - Filters
- ASP.NET MVC - Selectors
- ASP.NET MVC - Views
- ASP.NET MVC - Data Model
- ASP.NET MVC - Helpers
- ASP.NET MVC - Model Binding
- ASP.NET MVC - Databases
- ASP.NET MVC - Validation
- ASP.NET MVC - Security
- ASP.NET MVC - Caching
- ASP.NET MVC - Razor
- ASP.NET MVC - Data Annotations
- Nuget Package Management
- ASP.NET MVC - Web API
- ASP.NET MVC - Scaffolding
- ASP.NET MVC - Bootstrap
- ASP.NET MVC - Unit Testing
- ASP.NET MVC - Deployment
- ASP.NET MVC - Self-hosting
- ASP.NET MVC Useful Resources
- ASP.NET MVC - Quick Guide
- ASP.NET MVC - Useful Resources
- ASP.NET MVC - Discussion
ASP.NET MVC - Self-hosting
In this chapter, we will cover Self-Hosting. Self-Hosting creates a runtime environment for the application 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 application is completed and you want to use selfhosting, right-click on the Project in the solution explorer.
![Use Self-Hosting](/asp.net_mvc/images/use_self_hosting.jpg)
You will see the following dialog.
![Self-Hosting Dialog Box](/asp.net_mvc/images/self_hosting_dialog_box.jpg)
Step 2 − Click the ‘Custom’ option, which will display the New Custom Profile dialog.
![New Custom Profile dialog](/asp.net_mvc/images/new_custom_profile_dialog.jpg)
Step 3 − Enter the profile name and click Ok.
![Enter Profile Name](/asp.net_mvc/images/enter_profile_name.jpg)
Step 4 − Select the File System from the Publish method dropdown list and also specify the target location. Click ‘Next’ button.
![Select File System](/asp.net_mvc/images/select_file_system.jpg)
Step 5 − Expand the File Publish Options.
![File Publish Options](/asp.net_mvc/images/file_publish_options.jpg)
Step 6 − Check the ‘Delete all existing files prior to publish’ and ‘Precompile during publishing’ checkboxes and click ‘Next’ to continue.
![Delete all Existing Files](/asp.net_mvc/images/delete_all_existing_files.jpg)
Step 7 − Click ‘Publish’ button, it will publish the files at the desired location.
![Publish Files at Desired Location](/asp.net_mvc/images/publish_files_desired_location.jpg)
You will see all the files and folders in the target location on your system.
![Target Location](/asp.net_mvc/images/target_location.jpg)
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 → Application Development Features.
![Open Turn Windows Features](/asp.net_mvc/images/open_turn_windows_features.jpg)
Step 9 − Check the checkboxes as shown in the above screenshot and click Ok.
Step 10 − Let’s open the IIS Manager as shown in the following screenshot.
![IIS Manager](/asp.net_mvc/images/iis_manager.jpg)
Step 11 − You will see different connections on the left side of the screen, right-click on MyWebSite.
![Different Connections](/asp.net_mvc/images/different_connections.jpg)
Step 12 − Select the ‘Convert to Application’ option.
![Convert to Application](/asp.net_mvc/images/convert_application.jpg)
As you can see, its physical path is the same as we have mentioned above while publishing, using the File system.
Step 13 − Click Ok to continue.
![Click OK](/asp.net_mvc/images/click_ok.jpg)
Now you can see that its icon has changed.
Step 14 − Open your browser and specify the following URL http://localhost/MyWebSite
![Specify URL](/asp.net_mvc/images/specify_url.jpg)
You can see that it is running from the folder which we have specified during deployment.