DNS Host File Not Working (ASP.Net Core 3.1)

Problem: When developing for Web, you might be in a situetion where you need to get access to same site cookies (for privacy reasons, only sites permitted to get access to the cookies are those of the same domain. No other different sites are permitted to see other sites cookies).

- If you are developing for a prominent Website and need to test for cookies, remember the rule, only site with the domain name registered should have access to the cookies. How do you get access to the cookies for testing when using a localhost as a domain name for development purposes?


1. Navigate to the Host file and update the DNS entry like so: www.siteNameDomainYouWantToTestFor.com #There is one space in between IP and Domain
2. Save the Host file, make sure you don't save the file with an extension, else it won't work.
3. Flush the DNS on your computer if you have tested and it does not work.
    - Open up Powershell and enter the command: ipconfig /flushdns
4. If developing in ASP.Net Core 3.1, Open up Visual Studio and navigate to launchSettings.json under Properties dropdown in Solution Explorer.
   - Change the listening port from https://localhost:5001 to https://localhost:80 . Remember in some case, this step is not required, the configuration works.
5. [Important]: Your browser caches DNS, to test for this, open up a new tab in Incognito and enter www.siteNameDomainYouWantToTestFor.com

Edit this Article
asp.net Core 3.1 asp.net mvc asp.net core errors asp.net web forms asp.net core tutorial Technology published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy