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?

 


Login to See the Rest of the Answer

Answer: 

1. Navigate to the Host file and update the DNS entry like so: 127.0.0.1 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







For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]