Compartir a través de


Hosts, IP Addresses, and Testing

Hosts, IP Addresses, and Testing

It may be necessary to use a slightly modified client browser when testing your Microsoft® .NET Passport implementation in the early stages, especially in the early stages of testing against the Production environment. Specifically, the client testing browser may need to have a locally modified HOSTS file that is used to defeat server-based name resolution of your own site's URLs.

Ordinarily, a server that is not yet in an active rotation can be tested by accessing it by its IP address rather than by host name. However, this approach cannot be used to test .NET Passport services, because .NET Passport servers typically verify that return URLs fall within the root domain assigned for your particular Site ID. If a .NET Passport server receives a specific server IP address instead of a host name in a return URL, the server code has no way of verifying that this particular IP address falls within your site's specified root domain.

For example, if it receives a return URL of https://207.46.230.219/default.htm and the Site ID that is appropriate for the Microsoft.com domain, a .NET Passport server cannot verify that this server actually is within the Microsoft.com root domain. It will therefore not redirect any .NET Passport information back to this URL and will display a warning page to the browser user. "Localhost" cannot be used in a return URL for the same reason.

The workaround to this problem is to place the mapping of IP addresses to the host name of the server you wish to test against in the HOSTS file of the computer on which you are running the browser test. For example, the computer running Passport Manager has an IP address of 207.46.230.219 and the site to which it will soon belong is named www.mysite.com. The computer on which you will do your browser test is named \\testmachine. On \\testmachine, add an entry to the local HOSTS file (in Microsoft® Windows®, this is located in the folder %SYSTEM ROOT%\System32\drivers\etc\). Note that the file has no extension. In that file, add the line:

207.46.230.219		www.mysite.com

Restart the \\testmachine to ensure the new IP mapping has taken effect. The result will be that when you open the browser on \\testmachine and enter the site name www.mysite.com, the browser will display pages from 207.46.230.219 and the returnUrl parameter that is passed to the .NET Passport system servers will contain www.mysite.com.

Notes

  • The exact location and syntax of such a HOSTS file is potentially different depending on operating system, browser, or network layer. This example is for a Microsoft® Internet Explorer browser running under WinInet on a Windows operating system computer.

  • It may be necessary to restart the test browser computer after making changes to the HOSTS file in order for the changes to be recognized.

  • You might want to save any modified HOSTS files for future use or for copying to other browsers used for testing.

  • It is possible to map specific ports in an IP request to specific host names. This can be useful if you are testing a server that will ultimately be responsible for serving under multiple host names. For more information, see Configuring Multiple Sites. It is also possible to map multiple host names to the same IP address. For more information about HOSTS files and IP mapping, see MSDN .

See Also

.NET Passport Environments | Test Mode | Deploying Passport Manager and Site Code