So your are working on a website on your local dev machine and maybe you want to run the website in Local IIS with a custom url. You don't want to run it as an application under the default website, you want it to be a website on it's own with a custom url. So you need to get that custom url to point to your localhost, basically

Old Way

Here is how you would normally do it by adding the url to the host file:

  1. Open Notepad as an administrator by right-clicking on it in the start menu and choosing 'Run as administrator'
    Click File > Open > C:\Windows\System32\drivers\etc

  2. Above the open button where it says TextDocuments (*.txt) change it to All Files (*.*)

  3. Then select the file named hosts and click on Open.

  4. Add a new line at the bottom of the file like this: codeshare.local

  5. The number on the left is the IP address where you want that url to point to. Leave it as so it points to your machine. the address on the right is the address of your site. Notice that it doesn't need http:// in front of if here.

  6. Save the file.

New Way

Here is how you can do it now.

  1. Just think of a url which ends with like this:

How does it work?

Some kind person has set up the domain and set the DNS for * to point to, so basically it just points to your local machine.

Go ahead and try it.

To test it out, you could use the command line to do the following:


You will see it replies from So there is no need to edit your hosts file any more for local development urls.

I was really pleased when I found this out from one of my YouTube subscribers, so I thought I should share it with you.

Please share this with others to let them know about it.


Thanks to brunty and cemerson from the Tech Nottingham Slack Group for pointing out some security concerns with this. They were concerned that the domain owner could point the traffic to a malware site or something like that, which is a valid point, but I trust the person who registered the domain.

If you don't trust the person who set this domain up, you could always register a domain for yourself and point the subdomains to to achieve the same thing.

Want to thank me?

If I've helped you out and you want to thank me, why not buy me a coffee?

Buy me a coffee

About the author

Paul Seal

Umbraco MVP and .NET Web Developer from Derby (UK) who specialises in building Content Management System (CMS) websites using MVC with Umbraco as a framework. Paul is passionate about web development and programming as a whole. Apart from when he's with his wife and son, if he's not writing code, he's thinking about it or listening to a podcast about it.

Related Posts

How to create a dynamic image from multiple images using ImageProcessor

This post shows you how I created a handler to create dynamic header images for my umbraco website u…

Read Post

How to send Slack messages programmatically using C#

In this post I show you how you can send Slack messages programmatically using C#

Read Post

Cyber Monday Deals

As it is Cyber Monday and you are probably looking for some tech related deals, I thought I would cr…

Read Post

How to get the swagger JSON file from a Web API

If you need to know the url to get the swagger json file, then this is the post for you.

Read Post