Set Custom Domain Name for localhost Website in IIS (2024)

Here you will learn how to set a custom domain name to a website running at a localhost. In this way, instead of running and debugging the website using the localhost url (such as http://localhost:), it can be run using a dummy domain name e.g., www.mywebsite.com.

Setting up a custom domain name instead of a localhost will help you when testing of many things, such as redirecting a non-www to a www website or vice-versa, or redirecting from http to https before publishing a website to the production/hosting environment.

We have already created an ASP.NET MVC application in Visual Studio 2017 which runs with the url http://localhost:51737 (you may have a different port number), as shown below.

Set Custom Domain Name for localhost Website in IIS (1)

Now, we want to use our dummy domain name http://www.mywebsite.com instead of http://localhost:51737.

We will take the following steps:

  1. Publish the website in the local folder
  2. Create a new website in the local IIS
  3. Change the hosts file

Publish a Website in the Local Folder

Right click on the project name in the solution explorer of Visual Studio (2015/2017) and click Publish to publish your website to the local file system.

You may need to create a new publishing profile for the file system publish target by clicking on the New Profile.. link. Select an appropriate folder and click the Create Profile button, as shown below.

Set Custom Domain Name for localhost Website in IIS (2)

This will add a FolderProfile as shown below. Now, click on the Publish button to publish your website to the selected folder.

Set Custom Domain Name for localhost Website in IIS (3)

After successfully publishing a website, open the local IIS manager (enter inetmgr in the Run window).

In the IIS manager, right click on Sites, click Add Web Site.. and enter the site name, physical path and hostname as www.mywebsite.com, as shown below.

Set Custom Domain Name for localhost Website in IIS (4)

This will create a website on the local IIS server.

Now, we want to use http://www.mywebsite.com instead of the localhost url. For this, we have to open the hosts file located in the C:\Windows\System32\drivers\etc\ in Windows Vista, 7 and 8. The hosts file for Unix, Linux, and Mac OS X is located in /etc/hosts. Open hosts file as an administrator.

Add "127.0.0.1 www.mywebsite.com" at the end of the file, as shown below. This will tell IIS to search for the local website when www.mywebsite.com url is entered.

Set Custom Domain Name for localhost Website in IIS (5)

Now, we can enter www.mywebsite.com in the browser which will display our local website as shown below.

Set Custom Domain Name for localhost Website in IIS (6)

Learn how to create and install the SSL certificate for the localhost website.

Debug localhost Website with Custom Domain in Visual Studio

Now, let's see, how to debug a localhost website with the custom domain?

To debug your ASP.NET application in Visual Studio, we must publish it in the debug mode. For this, change your publishing profile and set the debug configuration, as shown below.

Set Custom Domain Name for localhost Website in IIS (7)

After publishing the website in debug mode, access your website e.g., www.mywebsite.com or https://www.mywebsite.com.

Now, to debug in Visual Studio, go to Debug -> Attach to Process.. menu. Select the w3wp.exe process from the popup, as shown below (if not listed, then check the 'Select processes from all users' checkbox).

Set Custom Domain Name for localhost Website in IIS (8)

Click on the Attach button to attach the process.

Now, you will be able to put a break point and start debugging, as shown below.

Set Custom Domain Name for localhost Website in IIS (9)

This is how you can set custom domain name for the localhost website and also debug it.

Set Custom Domain Name for localhost Website in IIS (10)

TutorialsTeacher

Author

We are a team of passionate developers, educators, and technology enthusiasts who, with their combined expertise and experience, create in-depth, comprehensive, and easy to understand tutorials. We focus on a blend of theoretical explanations and practical examples to encourages hands-on learning. Learn more about us

Set Custom Domain Name for localhost Website in IIS (2024)
Top Articles
Item coding in the warehouse
General Knowledge Questions Every Student Should Know
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Toyota Campers For Sale Craigslist
Unlocking the Enigmatic Tonicamille: A Journey from Small Town to Social Media Stardom
Ncaaf Reference
Globe Position Fault Litter Robot
Crusader Kings 3 Workshop
Robert Malone é o inventor da vacina mRNA e está certo sobre vacinação de crianças #boato
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 5688

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.